evo360-types 1.3.570 → 1.3.578

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.
Files changed (58) hide show
  1. package/dist/apps/evo-crm/lead/zod-schemas.d.ts +18 -9
  2. package/dist/apps/evo-csq/zod-schemas.d.ts +12 -12
  3. package/dist/apps/evo-finops/zod-schemas.d.ts +18 -18
  4. package/dist/apps/evo-med/calendar/zod-schemas.d.ts +535 -0
  5. package/dist/apps/evo-med/calendar/zod-schemas.js +52 -1
  6. package/dist/apps/evo-med/calendar/zod-schemas.ts +55 -0
  7. package/dist/apps/evo-med/dic/zod-schemas.d.ts +2 -2
  8. package/dist/apps/evo-med/insurance/zod-schemas.d.ts +9 -0
  9. package/dist/apps/evo-med/people/zod-schemas.d.ts +63 -45
  10. package/dist/apps/evo-notifications/quick-reply-action/zod-schemas.d.ts +3 -0
  11. package/dist/apps/evo-notifications/quick-reply-action/zod-schemas.js +3 -0
  12. package/dist/apps/evo-notifications/quick-reply-action/zod-schemas.ts +3 -0
  13. package/dist/apps/evo-notifications/zod-schemas.d.ts +69 -39
  14. package/dist/apps/evo-task/zod-schemas.d.ts +69 -69
  15. package/dist/apps/evo-task/zod-schemas.js +8 -0
  16. package/dist/apps/evo-task/zod-schemas.ts +8 -0
  17. package/dist/apps/evo-telemedicine/zod-schemas.d.ts +1567 -0
  18. package/dist/apps/evo-telemedicine/zod-schemas.js +709 -0
  19. package/dist/apps/evo-telemedicine/zod-schemas.ts +794 -0
  20. package/dist/apps/evo-tenant/zod-schemas.d.ts +94 -0
  21. package/dist/apps/evo-tenant/zod-schemas.js +29 -1
  22. package/dist/apps/evo-tenant/zod-schemas.ts +32 -1
  23. package/dist/apps/hub-automation/zod-schemas.d.ts +172 -172
  24. package/dist/apps/shared/zod-schemas.d.ts +3 -0
  25. package/dist/apps/shared/zod-schemas.js +2 -0
  26. package/dist/apps/shared/zod-schemas.ts +2 -0
  27. package/dist/index.d.ts +2 -0
  28. package/dist/index.js +2 -0
  29. package/dist/index.ts +2 -0
  30. package/dist/types/evo-finops/common/contract.d.ts +8 -0
  31. package/dist/types/evo-finops/common/contract.js +7 -0
  32. package/dist/types/evo-finops/common/contract.ts +7 -0
  33. package/dist/types/evo-med/calendar/index.d.ts +104 -0
  34. package/dist/types/evo-med/calendar/index.js +66 -1
  35. package/dist/types/evo-med/calendar/index.ts +146 -0
  36. package/dist/types/evo-notifications/index.d.ts +13 -0
  37. package/dist/types/evo-notifications/index.js +6 -0
  38. package/dist/types/evo-notifications/index.ts +13 -0
  39. package/dist/types/evo-reports/index.d.ts +27 -0
  40. package/dist/types/evo-reports/index.ts +28 -0
  41. package/dist/types/evo-task/index.d.ts +1 -0
  42. package/dist/types/evo-task/index.js +8 -0
  43. package/dist/types/evo-task/index.ts +8 -0
  44. package/dist/types/evo-telemedicine/fb_collections.d.ts +16 -0
  45. package/dist/types/evo-telemedicine/fb_collections.js +38 -0
  46. package/dist/types/evo-telemedicine/fb_collections.ts +37 -0
  47. package/dist/types/evo-telemedicine/index.d.ts +1137 -0
  48. package/dist/types/evo-telemedicine/index.js +387 -0
  49. package/dist/types/evo-telemedicine/index.ts +1299 -0
  50. package/dist/types/evo-tenant/index.d.ts +45 -0
  51. package/dist/types/evo-tenant/index.js +20 -1
  52. package/dist/types/evo-tenant/index.ts +65 -0
  53. package/dist/types/shared/external-links.d.ts +6 -0
  54. package/dist/types/shared/external-links.js +6 -0
  55. package/dist/types/shared/external-links.ts +6 -0
  56. package/dist/types/shared/index.d.ts +1 -0
  57. package/dist/types/shared/index.ts +2 -0
  58. package/package.json +1 -1
@@ -0,0 +1,709 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.zAccessRevokeCommandSchema = exports.zAccessSendCommandSchema = exports.zReassignHostCommandSchema = exports.zWaitingPolicyCommandSchema = exports.zTelemedicineGrantIndexSchema = exports.zTelemedicineTranscriptionConfigSchema = exports.zTelemedicineRolloutSchema = exports.zTelemedicineLegalTextSchema = exports.zTelemedicineEntitlementAuditSchema = exports.zTelemedicineAppointmentIndexSchema = exports.zTeleconsultationAccessGrantSchema = exports.zTeleconsultationWebhookEventSchema = exports.zTeleconsultationEventSchema = exports.zTeleconsultationArtifactSchema = exports.zTeleconsultationConsentSchema = exports.zTeleconsultationConsentEvidenceSchema = exports.zTeleconsultationParticipantSchema = exports.zTeleconsultationPrivateProviderSchema = exports.zTeleconsultationSchema = exports.zTeleconsultationEventActorSchema = exports.zTeleconsultationEntitlementSnapshotSchema = exports.zTeleconsultationEndedBySchema = exports.zTeleconsultationEventMetadataSchema = exports.zTelemedicineErrorCodeSchema = exports.zEntitlementAuditActionSchema = exports.zTranscriptionProviderSchema = exports.zLegalTextStatusSchema = exports.zWebhookEventStatusSchema = exports.zTeleconsultationEventTypeSchema = exports.zTeleconsultationEventSourceSchema = exports.zTeleconsultationEventActorTypeSchema = exports.zEndedByTypeSchema = exports.zAccessSendChannelKindSchema = exports.zAccessGrantStateSchema = exports.zAccessGrantKindSchema = exports.zArtifactStatusSchema = exports.zArtifactTypeSchema = exports.zConsentActorTypeSchema = exports.zConsentDecisionSchema = exports.zConsentSubjectSchema = exports.zTranscriptionStatusSchema = exports.zRecordingStatusSchema = exports.zIdentityLevelSchema = exports.zPresenceStateSchema = exports.zParticipantStateSchema = exports.zParticipantRoleSchema = exports.zTeleconsultationProviderSchema = exports.zTeleconsultationModeSchema = exports.zWaitingPolicySchema = exports.zTeleconsultationStatusSchema = void 0;
4
+ exports.zTelemetryCommandSchema = exports.zRecordingStopCommandSchema = exports.zRecordingConsentCommandSchema = exports.zRecordingRequestCommandSchema = exports.zRejectCommandSchema = exports.zAdmitCommandSchema = exports.zPresenceCommandSchema = exports.zLeaveCommandSchema = exports.zJoinCommandSchema = exports.zConsentCommandSchema = exports.zIdentityVerifyCommandSchema = exports.zExchangeCommandSchema = exports.zEndCommandSchema = void 0;
5
+ const zod_1 = require("zod");
6
+ const zod_schemas_1 = require("../shared/zod-schemas");
7
+ const zod_schemas_2 = require("../evo-tenant/zod-schemas");
8
+ // ======================================================
9
+ // evo-telemedicine (feat-160) — zod schemas
10
+ //
11
+ // Espelhos À MÃO dos enums/interfaces em types/evo-telemedicine/index.ts (o
12
+ // repo não gera um lado a partir do outro). Ao acrescentar um valor no `*Enum`
13
+ // TS, acrescente aqui — e vice-versa. Doc schemas usam `.passthrough()` para
14
+ // tolerar campos aditivos sem republish; command schemas são ESTRITOS (fronteira
15
+ // HTTP) e nunca aceitam `tenant` no body.
16
+ // ======================================================
17
+ // ----- Enums ----------------------------------------------------------------
18
+ /** Espelha `TeleconsultationStatusEnum`. */
19
+ exports.zTeleconsultationStatusSchema = zod_1.z.enum([
20
+ "scheduled",
21
+ "open",
22
+ "live",
23
+ "reconnecting",
24
+ "ending",
25
+ "ended",
26
+ "cancelled",
27
+ "expired",
28
+ ]);
29
+ /** Espelha `WaitingPolicyEnum`. */
30
+ exports.zWaitingPolicySchema = zod_1.z.enum([
31
+ "manual_admit",
32
+ "auto_when_doctor_present",
33
+ ]);
34
+ /** Espelha `TeleconsultationModeEnum`. */
35
+ exports.zTeleconsultationModeSchema = zod_1.z.enum([
36
+ "audio_video",
37
+ "audio_only_allowed",
38
+ ]);
39
+ /** Espelha `TeleconsultationProviderEnum`. */
40
+ exports.zTeleconsultationProviderSchema = zod_1.z.enum(["realtimekit"]);
41
+ /** Espelha `ParticipantRoleEnum`. */
42
+ exports.zParticipantRoleSchema = zod_1.z.enum(["doctor", "patient"]);
43
+ /** Espelha `ParticipantStateEnum`. */
44
+ exports.zParticipantStateSchema = zod_1.z.enum([
45
+ "invited",
46
+ "verified",
47
+ "waiting",
48
+ "connected",
49
+ "disconnected",
50
+ "left",
51
+ ]);
52
+ /** Espelha `PresenceStateEnum` (subconjunto reportável pelo cliente). */
53
+ exports.zPresenceStateSchema = zod_1.z.enum([
54
+ "waiting",
55
+ "connected",
56
+ "disconnected",
57
+ "left",
58
+ ]);
59
+ /** Espelha `IdentityLevelEnum`. */
60
+ exports.zIdentityLevelSchema = zod_1.z.enum(["none", "weak", "strong"]);
61
+ /** Espelha `RecordingStatusEnum`. */
62
+ exports.zRecordingStatusSchema = zod_1.z.enum([
63
+ "idle",
64
+ "consent_pending",
65
+ "recording",
66
+ "stopping",
67
+ "failed",
68
+ ]);
69
+ /** Espelha `TranscriptionStatusEnum`. */
70
+ exports.zTranscriptionStatusSchema = zod_1.z.enum([
71
+ "not_requested",
72
+ "queued",
73
+ "processing",
74
+ "ready",
75
+ "failed",
76
+ "deleted",
77
+ ]);
78
+ /** Espelha `ConsentSubjectEnum`. */
79
+ exports.zConsentSubjectSchema = zod_1.z.enum([
80
+ "terms",
81
+ "privacy",
82
+ "recording",
83
+ "transcription",
84
+ ]);
85
+ /** Espelha `ConsentDecisionEnum`. */
86
+ exports.zConsentDecisionSchema = zod_1.z.enum([
87
+ "accepted",
88
+ "declined",
89
+ "withdrawn",
90
+ ]);
91
+ /** Espelha `ConsentActorTypeEnum`. */
92
+ exports.zConsentActorTypeSchema = zod_1.z.enum(["patient", "doctor"]);
93
+ /** Espelha `ArtifactTypeEnum`. */
94
+ exports.zArtifactTypeSchema = zod_1.z.enum([
95
+ "recording_audio_video",
96
+ "recording_audio",
97
+ "transcript",
98
+ ]);
99
+ /** Espelha `ArtifactStatusEnum`. */
100
+ exports.zArtifactStatusSchema = zod_1.z.enum([
101
+ "pending",
102
+ "processing",
103
+ "ready",
104
+ "failed",
105
+ "deleting",
106
+ "deleted",
107
+ ]);
108
+ /** Espelha `AccessGrantKindEnum`. */
109
+ exports.zAccessGrantKindSchema = zod_1.z.enum([
110
+ "qr_capability",
111
+ "launch_code",
112
+ "browser_session",
113
+ // feat-160 F7: `kind` de uma ENTRADA do `grant-index`, nunca de um grant.
114
+ "ics_capability",
115
+ ]);
116
+ /** Espelha `AccessGrantStateEnum`. */
117
+ exports.zAccessGrantStateSchema = zod_1.z.enum([
118
+ "active",
119
+ "consumed",
120
+ "blocked",
121
+ "revoked",
122
+ "expired",
123
+ ]);
124
+ /** Espelha `AccessSendChannelKindEnum`. */
125
+ exports.zAccessSendChannelKindSchema = zod_1.z.enum([
126
+ "whatsapp",
127
+ "email",
128
+ "manual",
129
+ ]);
130
+ /** Espelha `EndedByTypeEnum`. */
131
+ exports.zEndedByTypeSchema = zod_1.z.enum(["user", "system"]);
132
+ /** Espelha `TeleconsultationEventActorTypeEnum`. */
133
+ exports.zTeleconsultationEventActorTypeSchema = zod_1.z.enum([
134
+ "user",
135
+ "patient",
136
+ "system",
137
+ "provider",
138
+ ]);
139
+ /** Espelha `TeleconsultationEventSourceEnum`. */
140
+ exports.zTeleconsultationEventSourceSchema = zod_1.z.enum([
141
+ "api",
142
+ "webhook",
143
+ "appointment_reconciler",
144
+ "retention_job",
145
+ "sweep",
146
+ ]);
147
+ /** Espelha `TeleconsultationEventTypeEnum`. ADITIVO: eventos já gravados dependem desta lista. */
148
+ exports.zTeleconsultationEventTypeSchema = zod_1.z.enum([
149
+ "teleconsultation.created",
150
+ "teleconsultation.rescheduled",
151
+ "teleconsultation.cancelled",
152
+ "teleconsultation.expired",
153
+ "teleconsultation.diverged",
154
+ "access.created",
155
+ "access.link_revealed",
156
+ "access.revoked",
157
+ "access.exchanged",
158
+ "access.verification_failed",
159
+ "access.blocked",
160
+ "host.claimed",
161
+ "host.reassigned",
162
+ "waiting_policy.changed",
163
+ "doctor.prepared",
164
+ "doctor.joined",
165
+ "doctor.disconnected",
166
+ "doctor.rejoined",
167
+ "doctor.left",
168
+ "patient.verified",
169
+ "patient.waiting",
170
+ "patient.admitted",
171
+ "patient.rejected",
172
+ "patient.joined",
173
+ "patient.disconnected",
174
+ "patient.rejoined",
175
+ "patient.left",
176
+ "recording.consent_requested",
177
+ "recording.consent_accepted",
178
+ "recording.consent_declined",
179
+ "recording.consent_withdrawn",
180
+ "recording.started",
181
+ "recording.stopped",
182
+ "recording.failed",
183
+ "transcription.queued",
184
+ "transcription.ready",
185
+ "transcription.failed",
186
+ "transcription.deleted",
187
+ "consultation.started",
188
+ "consultation.reconnecting",
189
+ "consultation.ended",
190
+ "artifact.accessed",
191
+ "artifact.deleted",
192
+ "entitlement.denied",
193
+ "rollout.denied",
194
+ "permission.denied",
195
+ "webhook.observed",
196
+ ]);
197
+ /** Espelha `WebhookEventStatusEnum`. */
198
+ exports.zWebhookEventStatusSchema = zod_1.z.enum([
199
+ "pending",
200
+ "claimed",
201
+ "completed",
202
+ "failed",
203
+ ]);
204
+ /** Espelha `LegalTextStatusEnum`. */
205
+ exports.zLegalTextStatusSchema = zod_1.z.enum(["draft", "published", "retired"]);
206
+ /** Espelha `TranscriptionProviderEnum`. */
207
+ exports.zTranscriptionProviderSchema = zod_1.z.enum(["none", "realtimekit"]);
208
+ /** Espelha `EntitlementAuditActionEnum`. */
209
+ exports.zEntitlementAuditActionSchema = zod_1.z.enum(["set", "override", "revoke"]);
210
+ /** Espelha `TelemedicineErrorCode`. */
211
+ exports.zTelemedicineErrorCodeSchema = zod_1.z.enum([
212
+ "TENANT_MODULE_DISABLED",
213
+ "ROLLOUT_DISABLED",
214
+ "EMERGENCY_KILL",
215
+ "PERMISSION_DENIED",
216
+ "CAPABILITY_DISABLED",
217
+ "NOT_FOUND",
218
+ "ACCESS_WINDOW_CLOSED",
219
+ "HOST_CLAIMED_BY_OTHER",
220
+ "HOST_REQUIRED",
221
+ "CONSENT_REQUIRED",
222
+ "IDENTITY_REQUIRED",
223
+ "IDENTITY_VERIFICATION_FAILED",
224
+ "GRANT_BLOCKED",
225
+ "GRANT_INVALID",
226
+ "SESSION_INVALID",
227
+ "TELECONSULTATION_TERMINAL",
228
+ "INVALID_TRANSITION",
229
+ "VERSION_CONFLICT",
230
+ "WAITING_POLICY_LOCKED",
231
+ "RECORDING_ACTIVE",
232
+ "RECORDING_FAILED",
233
+ "TRANSCRIPTION_GATE_CLOSED",
234
+ "ARTIFACT_NOT_READY",
235
+ "PROVIDER_ERROR",
236
+ "RATE_LIMITED",
237
+ "VALIDATION_ERROR",
238
+ ]);
239
+ // ----- Value objects ----------------------------------------------------------
240
+ const zDate = zod_schemas_1.zFirestoreDateSchema;
241
+ const zDateNullable = zod_schemas_1.zFirestoreDateSchema.nullable().optional();
242
+ /** Metadata allowlisted (sem PII/conteúdo médico): só primitivos. */
243
+ exports.zTeleconsultationEventMetadataSchema = zod_1.z.record(zod_1.z.string().min(1).max(60), zod_1.z.union([zod_1.z.string().max(500), zod_1.z.number(), zod_1.z.boolean()]));
244
+ exports.zTeleconsultationEndedBySchema = zod_1.z
245
+ .object({
246
+ type: exports.zEndedByTypeSchema,
247
+ id: zod_1.z.string().optional(),
248
+ reason: zod_1.z.string().min(1).max(120),
249
+ })
250
+ .passthrough();
251
+ exports.zTeleconsultationEntitlementSnapshotSchema = zod_1.z
252
+ .object({
253
+ version: zod_1.z.number().int().min(0),
254
+ capabilities: zod_1.z.record(zod_1.z.string(), zod_1.z.union([zod_1.z.boolean(), zod_1.z.number(), zod_1.z.string()])),
255
+ })
256
+ .passthrough();
257
+ exports.zTeleconsultationEventActorSchema = zod_1.z
258
+ .object({
259
+ type: exports.zTeleconsultationEventActorTypeSchema,
260
+ id: zod_1.z.string().optional(),
261
+ })
262
+ .passthrough();
263
+ // ----- Documentos (por tenant) -------------------------------------------------
264
+ /** Espelha `ITeleconsultation`. */
265
+ exports.zTeleconsultationSchema = zod_schemas_1.zFireDocSchema
266
+ .extend({
267
+ calendar_id: zod_1.z.string().min(1),
268
+ appointment_id: zod_1.z.string().min(1),
269
+ patient_id: zod_1.z.string().min(1),
270
+ scheduled_professional_id: zod_1.z.string().optional(),
271
+ claimed_host_user_id: zod_1.z.string().optional(),
272
+ claimed_host_at: zDateNullable,
273
+ mode: exports.zTeleconsultationModeSchema,
274
+ status: exports.zTeleconsultationStatusSchema,
275
+ waiting_policy: exports.zWaitingPolicySchema,
276
+ scheduled_start_at: zDate,
277
+ scheduled_end_at: zDate,
278
+ doctor_access_from: zDate,
279
+ patient_access_from: zDate,
280
+ unused_expires_at: zDate,
281
+ reconnect_until: zDateNullable,
282
+ started_at: zDateNullable,
283
+ ended_at: zDateNullable,
284
+ ended_by: exports.zTeleconsultationEndedBySchema.nullable().optional(),
285
+ provider: exports.zTeleconsultationProviderSchema,
286
+ provider_meeting_id: zod_1.z.string().optional(),
287
+ active_provider_session_id: zod_1.z.string().optional(),
288
+ recording_status: exports.zRecordingStatusSchema,
289
+ recording_request_id: zod_1.z.string().optional(),
290
+ recording_terms_version: zod_1.z.string().optional(),
291
+ recording_requested_at: zDateNullable,
292
+ recording_requested_by: zod_1.z.string().optional(),
293
+ recording_started_at: zDateNullable,
294
+ recording_stopped_at: zDateNullable,
295
+ recording_failure_code: zod_1.z.string().nullable().optional(),
296
+ recording_segment: zod_1.z.number().int().min(0).optional(),
297
+ transcription_status: exports.zTranscriptionStatusSchema,
298
+ provider_teardown_pending: zod_1.z.boolean().optional(),
299
+ metadata_retention_until: zDateNullable,
300
+ entitlement_snapshot: exports.zTeleconsultationEntitlementSnapshotSchema,
301
+ generation: zod_1.z.number().int().min(0),
302
+ reschedule_count: zod_1.z.number().int().min(0).optional(),
303
+ last_reconciled_appointment_version: zod_1.z
304
+ .union([zod_1.z.number(), zod_1.z.string()])
305
+ .nullable()
306
+ .optional(),
307
+ last_reconciled_at: zDateNullable,
308
+ usage_metering_due_at: zDateNullable,
309
+ usage_metered_at: zDateNullable,
310
+ version: zod_1.z.number().int().min(0),
311
+ })
312
+ .passthrough();
313
+ /**
314
+ * Espelha `ITeleconsultationPrivateProvider` (subdoc `private/provider`).
315
+ *
316
+ * NÃO estende `zFireDocSchema`: o subdoc não é um IFireDoc (não tem `version`
317
+ * de concorrência nem `ref`), e é lido sempre pelo backend com `id` do snap.
318
+ */
319
+ exports.zTeleconsultationPrivateProviderSchema = zod_1.z
320
+ .object({
321
+ id: zod_1.z.string(),
322
+ tenant: zod_1.z.string().min(1),
323
+ teleconsultation_id: zod_1.z.string().min(1),
324
+ provider: exports.zTeleconsultationProviderSchema,
325
+ provider_meeting_id: zod_1.z.string().optional(),
326
+ active_provider_session_id: zod_1.z.string().optional(),
327
+ provider_session_ids: zod_1.z.array(zod_1.z.string().min(1)).optional(),
328
+ provider_participant_ids: zod_1.z.record(zod_1.z.string(), zod_1.z.string()).optional(),
329
+ active_provider_recording_id: zod_1.z.string().nullable().optional(),
330
+ created_at: zDateNullable,
331
+ updated_at: zDateNullable,
332
+ })
333
+ .passthrough();
334
+ /** Espelha `ITeleconsultationParticipant`. */
335
+ exports.zTeleconsultationParticipantSchema = zod_schemas_1.zFireDocSchema
336
+ .extend({
337
+ teleconsultation_id: zod_1.z.string().min(1),
338
+ role: exports.zParticipantRoleSchema,
339
+ actor_user_id: zod_1.z.string().optional(),
340
+ patient_id: zod_1.z.string().optional(),
341
+ provider_participant_id: zod_1.z.string().optional(),
342
+ opaque_custom_participant_id: zod_1.z.string().min(1),
343
+ state: exports.zParticipantStateSchema,
344
+ identity_level: exports.zIdentityLevelSchema.optional(),
345
+ admitted_at: zDateNullable,
346
+ connected_at: zDateNullable,
347
+ last_seen_at: zDateNullable,
348
+ disconnected_at: zDateNullable,
349
+ reconnect_count: zod_1.z.number().int().min(0),
350
+ })
351
+ .passthrough();
352
+ exports.zTeleconsultationConsentEvidenceSchema = zod_1.z
353
+ .object({
354
+ ui_locale: zod_1.z.string().min(2).max(10),
355
+ session_id_hash: zod_1.z.string().min(1),
356
+ })
357
+ .passthrough();
358
+ /** Espelha `ITeleconsultationConsent`. */
359
+ exports.zTeleconsultationConsentSchema = zod_schemas_1.zFireDocSchema
360
+ .extend({
361
+ teleconsultation_id: zod_1.z.string().min(1),
362
+ subject: exports.zConsentSubjectSchema,
363
+ decision: exports.zConsentDecisionSchema,
364
+ terms_version: zod_1.z.string().min(1).max(40),
365
+ terms_content_hash: zod_1.z.string().optional(),
366
+ participant_id: zod_1.z.string().min(1),
367
+ actor_type: exports.zConsentActorTypeSchema,
368
+ occurred_at: zDate,
369
+ correlation_id: zod_1.z.string().min(1),
370
+ recording_request_id: zod_1.z.string().optional(),
371
+ evidence: exports.zTeleconsultationConsentEvidenceSchema,
372
+ })
373
+ .passthrough();
374
+ /** Espelha `ITeleconsultationArtifact`. */
375
+ exports.zTeleconsultationArtifactSchema = zod_schemas_1.zFireDocSchema
376
+ .extend({
377
+ teleconsultation_id: zod_1.z.string().min(1),
378
+ type: exports.zArtifactTypeSchema,
379
+ segment: zod_1.z.number().int().min(1),
380
+ status: exports.zArtifactStatusSchema,
381
+ provider_artifact_id: zod_1.z.string().optional(),
382
+ provider_session_id: zod_1.z.string().optional(),
383
+ recording_request_id: zod_1.z.string().optional(),
384
+ storage_bucket: zod_1.z.string().optional(),
385
+ storage_object: zod_1.z.string().optional(),
386
+ content_type: zod_1.z.string().optional(),
387
+ size_bytes: zod_1.z.number().int().min(0).optional(),
388
+ checksum: zod_1.z.string().optional(),
389
+ started_at: zDateNullable,
390
+ ended_at: zDateNullable,
391
+ expires_at: zDateNullable,
392
+ deleted_at: zDateNullable,
393
+ error_code: zod_1.z.string().optional(),
394
+ })
395
+ .passthrough();
396
+ /** Espelha `ITeleconsultationEvent` (append-only). */
397
+ exports.zTeleconsultationEventSchema = zod_schemas_1.zFireDocSchema
398
+ .extend({
399
+ teleconsultation_id: zod_1.z.string().min(1),
400
+ type: exports.zTeleconsultationEventTypeSchema,
401
+ occurred_at: zDate,
402
+ actor: exports.zTeleconsultationEventActorSchema,
403
+ source: exports.zTeleconsultationEventSourceSchema,
404
+ correlation_id: zod_1.z.string().min(1),
405
+ causation_id: zod_1.z.string().optional(),
406
+ idempotency_key: zod_1.z.string().optional(),
407
+ from_status: zod_1.z.string().optional(),
408
+ to_status: zod_1.z.string().optional(),
409
+ metadata: exports.zTeleconsultationEventMetadataSchema.optional(),
410
+ })
411
+ .passthrough();
412
+ /** Espelha `ITeleconsultationWebhookEvent` (dedup + outbox). */
413
+ exports.zTeleconsultationWebhookEventSchema = zod_schemas_1.zFireDocSchema
414
+ .extend({
415
+ teleconsultation_id: zod_1.z.string().optional(),
416
+ provider: exports.zTeleconsultationProviderSchema,
417
+ provider_event_id: zod_1.z.string().min(1),
418
+ event_type: zod_1.z.string().min(1),
419
+ payload_hash: zod_1.z.string().optional(),
420
+ sanitized_payload: zod_1.z
421
+ .record(zod_1.z.string(), zod_1.z.union([zod_1.z.string(), zod_1.z.number(), zod_1.z.boolean(), zod_1.z.null()]))
422
+ .optional(),
423
+ status: exports.zWebhookEventStatusSchema,
424
+ received_at: zDate,
425
+ claimed_at: zDateNullable,
426
+ claimed_by: zod_1.z.string().optional(),
427
+ lease_until: zDateNullable,
428
+ processed_at: zDateNullable,
429
+ attempt: zod_1.z.number().int().min(0),
430
+ next_attempt_at: zDateNullable,
431
+ result: zod_1.z.string().optional(),
432
+ error_code: zod_1.z.string().optional(),
433
+ correlation_id: zod_1.z.string().min(1),
434
+ expires_at: zDate,
435
+ })
436
+ .passthrough();
437
+ /** Espelha `ITeleconsultationAccessGrant`. `secret_hash` é HMAC — nunca o segredo. */
438
+ exports.zTeleconsultationAccessGrantSchema = zod_schemas_1.zFireDocSchema
439
+ .extend({
440
+ teleconsultation_id: zod_1.z.string().min(1),
441
+ role: exports.zParticipantRoleSchema,
442
+ kind: exports.zAccessGrantKindSchema,
443
+ secret_hash: zod_1.z.string().min(1),
444
+ recipient_ref_hash: zod_1.z.string().optional(),
445
+ actor_user_id: zod_1.z.string().optional(),
446
+ participant_id: zod_1.z.string().optional(),
447
+ state: exports.zAccessGrantStateSchema,
448
+ expires_at: zDate,
449
+ consumed_at: zDateNullable,
450
+ revoked_at: zDateNullable,
451
+ revoked_by: zod_1.z.string().optional(),
452
+ last_used_at: zDateNullable,
453
+ failed_attempts: zod_1.z.number().int().min(0),
454
+ failed_window_started_at: zDateNullable,
455
+ blocked_until: zDateNullable,
456
+ parent_grant_id: zod_1.z.string().optional(),
457
+ channel_kind: exports.zAccessSendChannelKindSchema.optional(),
458
+ quick_reply_action_id: zod_1.z.string().optional(),
459
+ version: zod_1.z.number().int().min(0),
460
+ })
461
+ .passthrough();
462
+ /** Espelha `ITelemedicineAppointmentIndex`. */
463
+ exports.zTelemedicineAppointmentIndexSchema = zod_schemas_1.zFireDocSchema
464
+ .extend({
465
+ calendar_id: zod_1.z.string().min(1),
466
+ appointment_id: zod_1.z.string().min(1),
467
+ active_teleconsultation_id: zod_1.z.string().nullable(),
468
+ generation: zod_1.z.number().int().min(0),
469
+ last_reconciled_appointment_version: zod_1.z
470
+ .union([zod_1.z.number(), zod_1.z.string()])
471
+ .nullable()
472
+ .optional(),
473
+ last_reconciled_at: zDateNullable,
474
+ last_teleconsultation_id: zod_1.z.string().nullable().optional(),
475
+ })
476
+ .passthrough();
477
+ /** Espelha `ITelemedicineEntitlementAudit`. */
478
+ exports.zTelemedicineEntitlementAuditSchema = zod_schemas_1.zFireDocSchema
479
+ .extend({
480
+ module: zod_1.z.string().min(1).max(40),
481
+ action: exports.zEntitlementAuditActionSchema,
482
+ before: zod_schemas_2.zTenantModuleEntitlementSchema.nullable().optional(),
483
+ after: zod_schemas_2.zTenantModuleEntitlementSchema,
484
+ actor: zod_1.z
485
+ .object({
486
+ type: zod_1.z.enum(["user", "system", "script"]),
487
+ id: zod_1.z.string().optional(),
488
+ })
489
+ .passthrough(),
490
+ reason: zod_1.z.string().min(1).max(500),
491
+ occurred_at: zDate,
492
+ correlation_id: zod_1.z.string().optional(),
493
+ })
494
+ .passthrough();
495
+ // ----- Documentos de plataforma -------------------------------------------------
496
+ // Docs globais (`IFireGlobalDoc`): sem `tenant`.
497
+ const zGlobalDocSchema = zod_1.z.object({
498
+ id: zod_1.z.string(),
499
+ ref: zod_1.z.any().optional(),
500
+ model_ver: zod_1.z.number().optional(),
501
+ version: zod_1.z.number().optional(),
502
+ created_at: zDateNullable,
503
+ updated_at: zDateNullable,
504
+ deleted_at: zDateNullable,
505
+ });
506
+ /** Espelha `ITelemedicineLegalText` (standalone: `version` aqui é a versão do texto). */
507
+ exports.zTelemedicineLegalTextSchema = zod_1.z
508
+ .object({
509
+ id: zod_1.z.string(),
510
+ subject: exports.zConsentSubjectSchema,
511
+ locale: zod_1.z.string().min(2).max(10),
512
+ version: zod_1.z.string().min(1).max(40),
513
+ title: zod_1.z.string().min(1).max(200),
514
+ content_html: zod_1.z.string().min(1),
515
+ content_hash: zod_1.z.string().min(1),
516
+ published_at: zDateNullable,
517
+ effective_at: zDateNullable,
518
+ status: exports.zLegalTextStatusSchema,
519
+ placeholders: zod_1.z.array(zod_1.z.string().min(1).max(60)).optional(),
520
+ created_at: zDateNullable,
521
+ updated_at: zDateNullable,
522
+ })
523
+ .passthrough();
524
+ /** Espelha `ITelemedicineRollout`. Ausência do doc = deny. */
525
+ exports.zTelemedicineRolloutSchema = zGlobalDocSchema
526
+ .extend({
527
+ create_enabled: zod_1.z.boolean(),
528
+ join_enabled: zod_1.z.boolean(),
529
+ recording_enabled: zod_1.z.boolean(),
530
+ transcription_enabled: zod_1.z.boolean(),
531
+ emergency_kill: zod_1.z.boolean(),
532
+ updated_at: zDate,
533
+ updated_by: zod_1.z.string().min(1),
534
+ })
535
+ .passthrough();
536
+ /** Espelha `ITelemedicineTranscriptionConfig`. */
537
+ exports.zTelemedicineTranscriptionConfigSchema = zGlobalDocSchema
538
+ .extend({
539
+ provider: exports.zTranscriptionProviderSchema,
540
+ production_gate_approved: zod_1.z.boolean(),
541
+ approved_by: zod_1.z.string().optional(),
542
+ approved_at: zDateNullable,
543
+ })
544
+ .passthrough();
545
+ /** Espelha `ITelemedicineGrantIndex`. */
546
+ exports.zTelemedicineGrantIndexSchema = zGlobalDocSchema
547
+ .extend({
548
+ tenant: zod_1.z.string().min(1),
549
+ teleconsultation_id: zod_1.z.string().min(1),
550
+ grant_id: zod_1.z.string().min(1),
551
+ kind: exports.zAccessGrantKindSchema.optional(),
552
+ expires_at: zDate,
553
+ })
554
+ .passthrough();
555
+ // ----- Comandos (request bodies — fronteira HTTP, estritos) --------------------
556
+ const zExpectedVersion = zod_1.z.number().int().min(0).optional();
557
+ const zReason = zod_1.z.string().trim().min(1).max(500);
558
+ /** `PATCH /waiting-policy` — espelha `IWaitingPolicyCommand`. */
559
+ exports.zWaitingPolicyCommandSchema = zod_1.z
560
+ .object({
561
+ waiting_policy: exports.zWaitingPolicySchema,
562
+ expected_version: zExpectedVersion,
563
+ })
564
+ .strict();
565
+ /** `POST /reassign-host` — espelha `IReassignHostCommand` (motivo obrigatório, D22). */
566
+ exports.zReassignHostCommandSchema = zod_1.z
567
+ .object({
568
+ to_user_id: zod_1.z.string().trim().min(1).max(128),
569
+ reason: zReason,
570
+ expected_version: zExpectedVersion,
571
+ })
572
+ .strict();
573
+ /** `POST /access/send` — espelha `IAccessSendCommand`. */
574
+ exports.zAccessSendCommandSchema = zod_1.z
575
+ .object({
576
+ channel_kind: exports.zAccessSendChannelKindSchema,
577
+ resend: zod_1.z.boolean().optional(),
578
+ })
579
+ .strict();
580
+ /** `POST /access/revoke` — espelha `IAccessRevokeCommand`. */
581
+ exports.zAccessRevokeCommandSchema = zod_1.z
582
+ .object({
583
+ grant_id: zod_1.z.string().trim().min(1).max(128).optional(),
584
+ reason: zReason,
585
+ })
586
+ .strict();
587
+ /** `POST /end` — espelha `IEndCommand`. */
588
+ exports.zEndCommandSchema = zod_1.z
589
+ .object({
590
+ reason: zod_1.z.string().trim().min(1).max(120).optional(),
591
+ expected_version: zExpectedVersion,
592
+ })
593
+ .strict();
594
+ /** `POST /api/room/v1/exchange` — espelha `IExchangeCommand` (code base64url de 128 bits = 22 chars). */
595
+ exports.zExchangeCommandSchema = zod_1.z
596
+ .object({
597
+ code: zod_1.z
598
+ .string()
599
+ .trim()
600
+ .min(16)
601
+ .max(128)
602
+ .regex(/^[A-Za-z0-9_-]+$/, "code must be base64url"),
603
+ })
604
+ .strict();
605
+ /** `POST /api/room/v1/identity/verify` — espelha `IIdentityVerifyCommand`. */
606
+ exports.zIdentityVerifyCommandSchema = zod_1.z
607
+ .object({
608
+ display_name: zod_1.z.string().trim().min(2).max(120),
609
+ // Normalizada no cliente para YYYY-MM-DD; o backend normaliza de novo antes
610
+ // da comparação constant-time. Erro de formato NÃO revela qual campo falhou.
611
+ birth_date: zod_1.z
612
+ .string()
613
+ .trim()
614
+ .regex(/^\d{4}-\d{2}-\d{2}$/, "birth_date must be YYYY-MM-DD")
615
+ .optional(),
616
+ })
617
+ .strict();
618
+ /** `POST /api/room/v1/consents` — espelha `IConsentCommand` (só `accepted|declined`; retirada é rota de gravação). */
619
+ exports.zConsentCommandSchema = zod_1.z
620
+ .object({
621
+ subject: exports.zConsentSubjectSchema,
622
+ terms_version: zod_1.z.string().trim().min(1).max(40),
623
+ decision: zod_1.z.enum(["accepted", "declined"]),
624
+ })
625
+ .strict();
626
+ /**
627
+ * `POST /api/room/v1/join` — espelha `IJoinCommand`.
628
+ *
629
+ * `.passthrough()`, não `.strict()`, ao contrário dos outros comandos: o
630
+ * backend hoje LÊ os dois booleanos à mão e ignora o resto, e o corpo é a
631
+ * intenção de mídia do preflight. Trocar por `.strict()` faria um campo novo do
632
+ * SPA derrubar o join inteiro em `400` — alto preço para um corpo que o
633
+ * servidor pode ignorar por completo.
634
+ */
635
+ exports.zJoinCommandSchema = zod_1.z
636
+ .object({
637
+ audio: zod_1.z.boolean().optional(),
638
+ video: zod_1.z.boolean().optional(),
639
+ })
640
+ .passthrough();
641
+ /**
642
+ * `POST /api/room/v1/leave` — espelha `ILeaveCommand`.
643
+ *
644
+ * `.passthrough()` pelo mesmo motivo, agravado: este corpo chega pelo
645
+ * `pagehide` com `fetch(keepalive)` e é a ÚLTIMA chance de registrar a saída.
646
+ * Um 400 aqui é uma saída perdida, e o backend já trata corpo ausente
647
+ * (`reason` default `'temporary'`).
648
+ */
649
+ exports.zLeaveCommandSchema = zod_1.z
650
+ .object({
651
+ reason: zod_1.z.string().trim().min(1).max(60).optional(),
652
+ })
653
+ .passthrough();
654
+ /** `POST /api/room/v1/presence` — espelha `IPresenceCommand`. */
655
+ exports.zPresenceCommandSchema = zod_1.z
656
+ .object({
657
+ state: exports.zPresenceStateSchema,
658
+ provider_participant_id: zod_1.z.string().trim().min(1).max(128).optional(),
659
+ })
660
+ .strict();
661
+ /** `POST /api/room/v1/admit` — espelha `IAdmitCommand`. */
662
+ exports.zAdmitCommandSchema = zod_1.z
663
+ .object({
664
+ participant_id: zod_1.z.string().trim().min(1).max(128),
665
+ })
666
+ .strict();
667
+ /** `POST /api/room/v1/reject` — espelha `IRejectCommand`. */
668
+ exports.zRejectCommandSchema = zod_1.z
669
+ .object({
670
+ participant_id: zod_1.z.string().trim().min(1).max(128),
671
+ reason: zod_1.z.string().trim().min(1).max(120).optional(),
672
+ })
673
+ .strict();
674
+ /** `POST /api/room/v1/recording/request` — espelha `IRecordingRequestCommand`. */
675
+ exports.zRecordingRequestCommandSchema = zod_1.z
676
+ .object({
677
+ recording_request_id: zod_1.z.string().trim().min(8).max(128),
678
+ })
679
+ .strict();
680
+ /** `POST /api/room/v1/recording/accept|decline|withdraw` — espelha `IRecordingConsentCommand`. */
681
+ exports.zRecordingConsentCommandSchema = zod_1.z
682
+ .object({
683
+ recording_request_id: zod_1.z.string().trim().min(8).max(128),
684
+ terms_version: zod_1.z.string().trim().min(1).max(40),
685
+ })
686
+ .strict();
687
+ /** `POST /api/room/v1/recording/stop` — espelha `IRecordingStopCommand`. */
688
+ exports.zRecordingStopCommandSchema = zod_1.z
689
+ .object({
690
+ recording_request_id: zod_1.z.string().trim().min(8).max(128).optional(),
691
+ })
692
+ .strict();
693
+ /** `POST /api/room/v1/telemetry` — espelha `ITelemetryCommand`; nomes allowlisted no backend. */
694
+ exports.zTelemetryCommandSchema = zod_1.z
695
+ .object({
696
+ events: zod_1.z
697
+ .array(zod_1.z
698
+ .object({
699
+ name: zod_1.z.string().trim().min(1).max(60),
700
+ at: zod_1.z.string().datetime({ offset: true }),
701
+ attrs: zod_1.z
702
+ .record(zod_1.z.string().min(1).max(40), zod_1.z.union([zod_1.z.string().max(200), zod_1.z.number(), zod_1.z.boolean()]))
703
+ .optional(),
704
+ })
705
+ .strict())
706
+ .min(1)
707
+ .max(50),
708
+ })
709
+ .strict();