evo360-types 1.3.128 → 1.3.129

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.
@@ -188,11 +188,11 @@ export declare const zAppointmentRescheduleSchema: z.ZodObject<{
188
188
  reason: z.ZodOptional<z.ZodString>;
189
189
  external_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
190
190
  userRef: z.ZodOptional<z.ZodAny>;
191
- created_at: z.ZodDate;
192
- oldStartDate: z.ZodOptional<z.ZodDate>;
193
- oldEndDate: z.ZodOptional<z.ZodDate>;
194
- newStartDate: z.ZodOptional<z.ZodDate>;
195
- newEndDate: z.ZodOptional<z.ZodDate>;
191
+ created_at: z.ZodEffects<z.ZodDate, Date, unknown>;
192
+ oldStartDate: z.ZodOptional<z.ZodEffects<z.ZodDate, Date, unknown>>;
193
+ oldEndDate: z.ZodOptional<z.ZodEffects<z.ZodDate, Date, unknown>>;
194
+ newStartDate: z.ZodOptional<z.ZodEffects<z.ZodDate, Date, unknown>>;
195
+ newEndDate: z.ZodOptional<z.ZodEffects<z.ZodDate, Date, unknown>>;
196
196
  }, "strip", z.ZodTypeAny, {
197
197
  created_at: Date;
198
198
  userRef?: any;
@@ -209,7 +209,7 @@ export declare const zAppointmentRescheduleSchema: z.ZodObject<{
209
209
  newStartDate?: Date | undefined;
210
210
  newEndDate?: Date | undefined;
211
211
  }, {
212
- created_at: Date;
212
+ created_at?: unknown;
213
213
  userRef?: any;
214
214
  external_id?: string | null | undefined;
215
215
  user_name?: string | undefined;
@@ -219,10 +219,10 @@ export declare const zAppointmentRescheduleSchema: z.ZodObject<{
219
219
  external_id?: string | null | undefined;
220
220
  } | undefined;
221
221
  reason?: string | undefined;
222
- oldStartDate?: Date | undefined;
223
- oldEndDate?: Date | undefined;
224
- newStartDate?: Date | undefined;
225
- newEndDate?: Date | undefined;
222
+ oldStartDate?: unknown;
223
+ oldEndDate?: unknown;
224
+ newStartDate?: unknown;
225
+ newEndDate?: unknown;
226
226
  }>;
227
227
  export declare const zAppointmentSpecialtySchema: z.ZodObject<{
228
228
  code: z.ZodString;
@@ -261,8 +261,8 @@ export declare const zAppointmentSchema: z.ZodObject<z.objectUtil.extendShape<{
261
261
  updated_at: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
262
262
  deleted_at: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
263
263
  }, {
264
- startDate: z.ZodDate;
265
- endDate: z.ZodDate;
264
+ startDate: z.ZodEffects<z.ZodDate, Date, unknown>;
265
+ endDate: z.ZodEffects<z.ZodDate, Date, unknown>;
266
266
  status: z.ZodString;
267
267
  statusBase: z.ZodEnum<["scheduled", "confirmed", "rescheduled", "pre_checkin", "waiting", "in_progress", "completed", "no_show", "cancelled", "cancelled_by_clinic", "cancelled_by_patient", "extra_slot", "awaiting_payment", "paid", "awaiting_documents", "blocked", "waiting_list", "expired"]>;
268
268
  notes: z.ZodOptional<z.ZodString>;
@@ -482,11 +482,11 @@ export declare const zAppointmentSchema: z.ZodObject<z.objectUtil.extendShape<{
482
482
  reason: z.ZodOptional<z.ZodString>;
483
483
  external_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
484
484
  userRef: z.ZodOptional<z.ZodAny>;
485
- created_at: z.ZodDate;
486
- oldStartDate: z.ZodOptional<z.ZodDate>;
487
- oldEndDate: z.ZodOptional<z.ZodDate>;
488
- newStartDate: z.ZodOptional<z.ZodDate>;
489
- newEndDate: z.ZodOptional<z.ZodDate>;
485
+ created_at: z.ZodEffects<z.ZodDate, Date, unknown>;
486
+ oldStartDate: z.ZodOptional<z.ZodEffects<z.ZodDate, Date, unknown>>;
487
+ oldEndDate: z.ZodOptional<z.ZodEffects<z.ZodDate, Date, unknown>>;
488
+ newStartDate: z.ZodOptional<z.ZodEffects<z.ZodDate, Date, unknown>>;
489
+ newEndDate: z.ZodOptional<z.ZodEffects<z.ZodDate, Date, unknown>>;
490
490
  }, "strip", z.ZodTypeAny, {
491
491
  created_at: Date;
492
492
  userRef?: any;
@@ -503,7 +503,7 @@ export declare const zAppointmentSchema: z.ZodObject<z.objectUtil.extendShape<{
503
503
  newStartDate?: Date | undefined;
504
504
  newEndDate?: Date | undefined;
505
505
  }, {
506
- created_at: Date;
506
+ created_at?: unknown;
507
507
  userRef?: any;
508
508
  external_id?: string | null | undefined;
509
509
  user_name?: string | undefined;
@@ -513,10 +513,10 @@ export declare const zAppointmentSchema: z.ZodObject<z.objectUtil.extendShape<{
513
513
  external_id?: string | null | undefined;
514
514
  } | undefined;
515
515
  reason?: string | undefined;
516
- oldStartDate?: Date | undefined;
517
- oldEndDate?: Date | undefined;
518
- newStartDate?: Date | undefined;
519
- newEndDate?: Date | undefined;
516
+ oldStartDate?: unknown;
517
+ oldEndDate?: unknown;
518
+ newStartDate?: unknown;
519
+ newEndDate?: unknown;
520
520
  }>, "many">>>;
521
521
  isDraft: z.ZodBoolean;
522
522
  draftExpirationMinutes: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
@@ -549,8 +549,8 @@ export declare const zAppointmentSchema: z.ZodObject<z.objectUtil.extendShape<{
549
549
  updated_at: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
550
550
  deleted_at: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
551
551
  }, {
552
- startDate: z.ZodDate;
553
- endDate: z.ZodDate;
552
+ startDate: z.ZodEffects<z.ZodDate, Date, unknown>;
553
+ endDate: z.ZodEffects<z.ZodDate, Date, unknown>;
554
554
  status: z.ZodString;
555
555
  statusBase: z.ZodEnum<["scheduled", "confirmed", "rescheduled", "pre_checkin", "waiting", "in_progress", "completed", "no_show", "cancelled", "cancelled_by_clinic", "cancelled_by_patient", "extra_slot", "awaiting_payment", "paid", "awaiting_documents", "blocked", "waiting_list", "expired"]>;
556
556
  notes: z.ZodOptional<z.ZodString>;
@@ -770,11 +770,11 @@ export declare const zAppointmentSchema: z.ZodObject<z.objectUtil.extendShape<{
770
770
  reason: z.ZodOptional<z.ZodString>;
771
771
  external_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
772
772
  userRef: z.ZodOptional<z.ZodAny>;
773
- created_at: z.ZodDate;
774
- oldStartDate: z.ZodOptional<z.ZodDate>;
775
- oldEndDate: z.ZodOptional<z.ZodDate>;
776
- newStartDate: z.ZodOptional<z.ZodDate>;
777
- newEndDate: z.ZodOptional<z.ZodDate>;
773
+ created_at: z.ZodEffects<z.ZodDate, Date, unknown>;
774
+ oldStartDate: z.ZodOptional<z.ZodEffects<z.ZodDate, Date, unknown>>;
775
+ oldEndDate: z.ZodOptional<z.ZodEffects<z.ZodDate, Date, unknown>>;
776
+ newStartDate: z.ZodOptional<z.ZodEffects<z.ZodDate, Date, unknown>>;
777
+ newEndDate: z.ZodOptional<z.ZodEffects<z.ZodDate, Date, unknown>>;
778
778
  }, "strip", z.ZodTypeAny, {
779
779
  created_at: Date;
780
780
  userRef?: any;
@@ -791,7 +791,7 @@ export declare const zAppointmentSchema: z.ZodObject<z.objectUtil.extendShape<{
791
791
  newStartDate?: Date | undefined;
792
792
  newEndDate?: Date | undefined;
793
793
  }, {
794
- created_at: Date;
794
+ created_at?: unknown;
795
795
  userRef?: any;
796
796
  external_id?: string | null | undefined;
797
797
  user_name?: string | undefined;
@@ -801,10 +801,10 @@ export declare const zAppointmentSchema: z.ZodObject<z.objectUtil.extendShape<{
801
801
  external_id?: string | null | undefined;
802
802
  } | undefined;
803
803
  reason?: string | undefined;
804
- oldStartDate?: Date | undefined;
805
- oldEndDate?: Date | undefined;
806
- newStartDate?: Date | undefined;
807
- newEndDate?: Date | undefined;
804
+ oldStartDate?: unknown;
805
+ oldEndDate?: unknown;
806
+ newStartDate?: unknown;
807
+ newEndDate?: unknown;
808
808
  }>, "many">>>;
809
809
  isDraft: z.ZodBoolean;
810
810
  draftExpirationMinutes: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
@@ -837,8 +837,8 @@ export declare const zAppointmentSchema: z.ZodObject<z.objectUtil.extendShape<{
837
837
  updated_at: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
838
838
  deleted_at: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
839
839
  }, {
840
- startDate: z.ZodDate;
841
- endDate: z.ZodDate;
840
+ startDate: z.ZodEffects<z.ZodDate, Date, unknown>;
841
+ endDate: z.ZodEffects<z.ZodDate, Date, unknown>;
842
842
  status: z.ZodString;
843
843
  statusBase: z.ZodEnum<["scheduled", "confirmed", "rescheduled", "pre_checkin", "waiting", "in_progress", "completed", "no_show", "cancelled", "cancelled_by_clinic", "cancelled_by_patient", "extra_slot", "awaiting_payment", "paid", "awaiting_documents", "blocked", "waiting_list", "expired"]>;
844
844
  notes: z.ZodOptional<z.ZodString>;
@@ -1058,11 +1058,11 @@ export declare const zAppointmentSchema: z.ZodObject<z.objectUtil.extendShape<{
1058
1058
  reason: z.ZodOptional<z.ZodString>;
1059
1059
  external_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1060
1060
  userRef: z.ZodOptional<z.ZodAny>;
1061
- created_at: z.ZodDate;
1062
- oldStartDate: z.ZodOptional<z.ZodDate>;
1063
- oldEndDate: z.ZodOptional<z.ZodDate>;
1064
- newStartDate: z.ZodOptional<z.ZodDate>;
1065
- newEndDate: z.ZodOptional<z.ZodDate>;
1061
+ created_at: z.ZodEffects<z.ZodDate, Date, unknown>;
1062
+ oldStartDate: z.ZodOptional<z.ZodEffects<z.ZodDate, Date, unknown>>;
1063
+ oldEndDate: z.ZodOptional<z.ZodEffects<z.ZodDate, Date, unknown>>;
1064
+ newStartDate: z.ZodOptional<z.ZodEffects<z.ZodDate, Date, unknown>>;
1065
+ newEndDate: z.ZodOptional<z.ZodEffects<z.ZodDate, Date, unknown>>;
1066
1066
  }, "strip", z.ZodTypeAny, {
1067
1067
  created_at: Date;
1068
1068
  userRef?: any;
@@ -1079,7 +1079,7 @@ export declare const zAppointmentSchema: z.ZodObject<z.objectUtil.extendShape<{
1079
1079
  newStartDate?: Date | undefined;
1080
1080
  newEndDate?: Date | undefined;
1081
1081
  }, {
1082
- created_at: Date;
1082
+ created_at?: unknown;
1083
1083
  userRef?: any;
1084
1084
  external_id?: string | null | undefined;
1085
1085
  user_name?: string | undefined;
@@ -1089,10 +1089,10 @@ export declare const zAppointmentSchema: z.ZodObject<z.objectUtil.extendShape<{
1089
1089
  external_id?: string | null | undefined;
1090
1090
  } | undefined;
1091
1091
  reason?: string | undefined;
1092
- oldStartDate?: Date | undefined;
1093
- oldEndDate?: Date | undefined;
1094
- newStartDate?: Date | undefined;
1095
- newEndDate?: Date | undefined;
1092
+ oldStartDate?: unknown;
1093
+ oldEndDate?: unknown;
1094
+ newStartDate?: unknown;
1095
+ newEndDate?: unknown;
1096
1096
  }>, "many">>>;
1097
1097
  isDraft: z.ZodBoolean;
1098
1098
  draftExpirationMinutes: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
@@ -134,11 +134,11 @@ exports.zAppointmentRescheduleSchema = zod_1.z.object({
134
134
  reason: zod_1.z.string().optional(), // Motivo do reagendamento (livre)
135
135
  external_id: zod_1.z.string().nullable().optional(), // ID externo do reagendamento
136
136
  userRef: zod_1.z.any().optional(), // Referência ao documento do usuário no Firestore
137
- created_at: zod_1.z.coerce.date(), // Data e hora em que o reagendamento foi realizado
138
- oldStartDate: zod_1.z.coerce.date().optional(), // Data/hora de início anterior do agendamento
139
- oldEndDate: zod_1.z.coerce.date().optional(), // Data/hora de término anterior do agendamento
140
- newStartDate: zod_1.z.coerce.date().optional(), // Data/hora de início nova do agendamento
141
- newEndDate: zod_1.z.coerce.date().optional(), // Data/hora de término nova do agendamento
137
+ created_at: zod_schemas_1.zFirestoreDateSchema, // Data e hora em que o reagendamento foi realizado
138
+ oldStartDate: zod_schemas_1.zFirestoreDateSchema.optional(), // Data/hora de início anterior do agendamento
139
+ oldEndDate: zod_schemas_1.zFirestoreDateSchema.optional(), // Data/hora de término anterior do agendamento
140
+ newStartDate: zod_schemas_1.zFirestoreDateSchema.optional(), // Data/hora de início nova do agendamento
141
+ newEndDate: zod_schemas_1.zFirestoreDateSchema.optional(), // Data/hora de término nova do agendamento
142
142
  });
143
143
  // Schema para especialidade no contexto de agendamento
144
144
  exports.zAppointmentSpecialtySchema = zod_1.z
@@ -156,8 +156,8 @@ exports.zAppointmentSpecialtySchema = zod_1.z
156
156
  // Schema principal do Appointment
157
157
  exports.zAppointmentSchema = zod_schemas_1.zFireDocSchema
158
158
  .extend({
159
- startDate: zod_1.z.coerce.date(),
160
- endDate: zod_1.z.coerce.date(),
159
+ startDate: zod_schemas_1.zFirestoreDateSchema,
160
+ endDate: zod_schemas_1.zFirestoreDateSchema,
161
161
  status: zod_1.z.string(), // Status customizado do dicionário
162
162
  statusBase: exports.zAppointmentStatusTypeSchema, // Tipo base para lógica
163
163
  notes: zod_1.z.string().optional(),
@@ -1,5 +1,9 @@
1
1
  import { z } from "zod";
2
- import { zFireDocSchema, zTagSchema } from "../../shared/zod-schemas";
2
+ import {
3
+ zFireDocSchema,
4
+ zTagSchema,
5
+ zFirestoreDateSchema,
6
+ } from "../../shared/zod-schemas";
3
7
 
4
8
  // Enums para validação
5
9
  export const zAppointmentPaymentStatusSchema = z.enum([
@@ -144,11 +148,11 @@ export const zAppointmentRescheduleSchema = z.object({
144
148
  reason: z.string().optional(), // Motivo do reagendamento (livre)
145
149
  external_id: z.string().nullable().optional(), // ID externo do reagendamento
146
150
  userRef: z.any().optional(), // Referência ao documento do usuário no Firestore
147
- created_at: z.coerce.date(), // Data e hora em que o reagendamento foi realizado
148
- oldStartDate: z.coerce.date().optional(), // Data/hora de início anterior do agendamento
149
- oldEndDate: z.coerce.date().optional(), // Data/hora de término anterior do agendamento
150
- newStartDate: z.coerce.date().optional(), // Data/hora de início nova do agendamento
151
- newEndDate: z.coerce.date().optional(), // Data/hora de término nova do agendamento
151
+ created_at: zFirestoreDateSchema, // Data e hora em que o reagendamento foi realizado
152
+ oldStartDate: zFirestoreDateSchema.optional(), // Data/hora de início anterior do agendamento
153
+ oldEndDate: zFirestoreDateSchema.optional(), // Data/hora de término anterior do agendamento
154
+ newStartDate: zFirestoreDateSchema.optional(), // Data/hora de início nova do agendamento
155
+ newEndDate: zFirestoreDateSchema.optional(), // Data/hora de término nova do agendamento
152
156
  });
153
157
 
154
158
  // Schema para especialidade no contexto de agendamento
@@ -168,8 +172,8 @@ export const zAppointmentSpecialtySchema = z
168
172
  // Schema principal do Appointment
169
173
  export const zAppointmentSchema = zFireDocSchema
170
174
  .extend({
171
- startDate: z.coerce.date(),
172
- endDate: z.coerce.date(),
175
+ startDate: zFirestoreDateSchema,
176
+ endDate: zFirestoreDateSchema,
173
177
  status: z.string(), // Status customizado do dicionário
174
178
  statusBase: zAppointmentStatusTypeSchema, // Tipo base para lógica
175
179
  notes: z.string().optional(),
@@ -1,5 +1,10 @@
1
1
  import { z } from "zod";
2
2
  export declare const zEvoAppSchema: z.ZodEnum<["evo-activity", "evo-core", "evo-crm", "evo-med", "evo-messages", "evo-people", "evo-survey", "evo-tags", "evo-task", "evo-tenant"]>;
3
+ /**
4
+ * Schema Zod que aceita datas de várias fontes, incluindo Timestamps do Firestore.
5
+ * Pode ser usado com .optional() ou .nullable().optional()
6
+ */
7
+ export declare const zFirestoreDateSchema: z.ZodEffects<z.ZodDate, Date, unknown>;
3
8
  export declare const zFireDocSchema: z.ZodObject<{
4
9
  id: z.ZodString;
5
10
  ref: z.ZodAny;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.zContactSchema = exports.zAddressSchema = exports.zTagSchema = exports.zFireDocSchema = exports.zEvoAppSchema = void 0;
3
+ exports.zContactSchema = exports.zAddressSchema = exports.zTagSchema = exports.zFireDocSchema = exports.zFirestoreDateSchema = exports.zEvoAppSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  // Enum for activity read status
6
6
  exports.zEvoAppSchema = zod_1.z.enum([
@@ -15,6 +15,42 @@ exports.zEvoAppSchema = zod_1.z.enum([
15
15
  "evo-task",
16
16
  "evo-tenant",
17
17
  ]);
18
+ /**
19
+ * Schema helper para converter Timestamps do Firestore para Date.
20
+ * Aceita: Date, string ISO, número (timestamp), Timestamp do Firestore, null/undefined
21
+ */
22
+ function convertFirestoreTimestamp(value) {
23
+ if (value === null || value === undefined) {
24
+ return value;
25
+ }
26
+ // Se já é uma Date, retorna direto
27
+ if (value instanceof Date) {
28
+ return value;
29
+ }
30
+ // Se é um objeto Timestamp do Firestore (tem método toDate)
31
+ if (typeof value === "object" &&
32
+ value !== null &&
33
+ "toDate" in value &&
34
+ typeof value.toDate === "function") {
35
+ return value.toDate();
36
+ }
37
+ // Se é um objeto com seconds e nanoseconds (estrutura do Firestore Timestamp)
38
+ if (typeof value === "object" &&
39
+ value !== null &&
40
+ "seconds" in value &&
41
+ typeof value.seconds === "number") {
42
+ const seconds = value.seconds;
43
+ const nanoseconds = value.nanoseconds || 0;
44
+ return new Date(seconds * 1000 + nanoseconds / 1000000);
45
+ }
46
+ // Para outros casos, deixa o z.coerce.date() fazer o trabalho
47
+ return value;
48
+ }
49
+ /**
50
+ * Schema Zod que aceita datas de várias fontes, incluindo Timestamps do Firestore.
51
+ * Pode ser usado com .optional() ou .nullable().optional()
52
+ */
53
+ exports.zFirestoreDateSchema = zod_1.z.preprocess(convertFirestoreTimestamp, zod_1.z.coerce.date());
18
54
  // Custom validation for FirestoreDocumentReference
19
55
  exports.zFireDocSchema = zod_1.z.object({
20
56
  id: zod_1.z.string(),
@@ -14,6 +14,55 @@ export const zEvoAppSchema = z.enum([
14
14
  "evo-tenant",
15
15
  ]);
16
16
 
17
+ /**
18
+ * Schema helper para converter Timestamps do Firestore para Date.
19
+ * Aceita: Date, string ISO, número (timestamp), Timestamp do Firestore, null/undefined
20
+ */
21
+ function convertFirestoreTimestamp(value: unknown): Date | null | undefined {
22
+ if (value === null || value === undefined) {
23
+ return value as null | undefined;
24
+ }
25
+
26
+ // Se já é uma Date, retorna direto
27
+ if (value instanceof Date) {
28
+ return value;
29
+ }
30
+
31
+ // Se é um objeto Timestamp do Firestore (tem método toDate)
32
+ if (
33
+ typeof value === "object" &&
34
+ value !== null &&
35
+ "toDate" in value &&
36
+ typeof (value as any).toDate === "function"
37
+ ) {
38
+ return (value as any).toDate();
39
+ }
40
+
41
+ // Se é um objeto com seconds e nanoseconds (estrutura do Firestore Timestamp)
42
+ if (
43
+ typeof value === "object" &&
44
+ value !== null &&
45
+ "seconds" in value &&
46
+ typeof (value as any).seconds === "number"
47
+ ) {
48
+ const seconds = (value as any).seconds;
49
+ const nanoseconds = (value as any).nanoseconds || 0;
50
+ return new Date(seconds * 1000 + nanoseconds / 1000000);
51
+ }
52
+
53
+ // Para outros casos, deixa o z.coerce.date() fazer o trabalho
54
+ return value as any;
55
+ }
56
+
57
+ /**
58
+ * Schema Zod que aceita datas de várias fontes, incluindo Timestamps do Firestore.
59
+ * Pode ser usado com .optional() ou .nullable().optional()
60
+ */
61
+ export const zFirestoreDateSchema = z.preprocess(
62
+ convertFirestoreTimestamp,
63
+ z.coerce.date()
64
+ );
65
+
17
66
  // Custom validation for FirestoreDocumentReference
18
67
  export const zFireDocSchema = z.object({
19
68
  id: z.string(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "evo360-types",
3
- "version": "1.3.128",
3
+ "version": "1.3.129",
4
4
  "description": "HREVO360 Shared Types",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",