evo360-types 1.3.552 → 1.3.555
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/dist/apps/evo-chat/ticket/zod-schemas.d.ts +66 -0
- package/dist/apps/evo-chat/ticket/zod-schemas.js +4 -0
- package/dist/apps/evo-chat/ticket/zod-schemas.ts +4 -0
- package/dist/apps/evo-core/zod-schemas.d.ts +30 -0
- package/dist/apps/evo-core/zod-schemas.js +2 -0
- package/dist/apps/evo-core/zod-schemas.ts +2 -0
- package/dist/apps/evo-csq/zod-schemas.d.ts +10414 -0
- package/dist/apps/evo-csq/zod-schemas.js +546 -0
- package/dist/apps/evo-csq/zod-schemas.ts +627 -0
- package/dist/apps/evo-finops/zod-schemas.d.ts +2 -2
- package/dist/apps/evo-hub-ia/v1/zod-schemas.d.ts +161 -0
- package/dist/apps/evo-hub-ia/v1/zod-schemas.js +43 -1
- package/dist/apps/evo-hub-ia/v1/zod-schemas.ts +46 -0
- package/dist/apps/hub-automation/zod-schemas.d.ts +18 -18
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.ts +2 -0
- package/dist/types/evo-chat/ticket/index.d.ts +4 -0
- package/dist/types/evo-chat/ticket/index.ts +5 -0
- package/dist/types/evo-core/index.d.ts +2 -0
- package/dist/types/evo-core/index.ts +2 -0
- package/dist/types/evo-csq/fb_collections.d.ts +5 -0
- package/dist/types/evo-csq/fb_collections.js +13 -0
- package/dist/types/evo-csq/fb_collections.ts +14 -0
- package/dist/types/evo-csq/index.d.ts +624 -0
- package/dist/types/evo-csq/index.js +180 -0
- package/dist/types/evo-csq/index.ts +888 -0
- package/dist/types/evo-hub-ia/v1/index.d.ts +37 -0
- package/dist/types/evo-hub-ia/v1/index.ts +44 -0
- package/package.json +1 -1
|
@@ -0,0 +1,627 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { zFireDocSchema, zFirestoreDateSchema } from "../shared/zod-schemas";
|
|
3
|
+
|
|
4
|
+
// Schemas zod do CSQ 2.0 (feat-154). As interfaces TS equivalentes ficam em
|
|
5
|
+
// src/types/evo-csq/index.ts e sao mantidas em paralelo (convencao do projeto:
|
|
6
|
+
// `apps/` = zod, `types/` = interfaces TS). Os literais abaixo sao contrato:
|
|
7
|
+
// mudou aqui, muda la (e vice-versa).
|
|
8
|
+
|
|
9
|
+
// ───────── Enums / Literals ─────────
|
|
10
|
+
|
|
11
|
+
/** CSQ por departamento: off (default) | shadow (avalia, nao notifica) | active. */
|
|
12
|
+
export const zCsqModeSchema = z.enum(["off", "shadow", "active"]);
|
|
13
|
+
export type ICsqMode = z.infer<typeof zCsqModeSchema>;
|
|
14
|
+
|
|
15
|
+
export const zCsqStatusSchema = z.enum([
|
|
16
|
+
"Excelente",
|
|
17
|
+
"Bom",
|
|
18
|
+
"Regular",
|
|
19
|
+
"Ruim",
|
|
20
|
+
"Crítico",
|
|
21
|
+
"pending_judge",
|
|
22
|
+
]);
|
|
23
|
+
|
|
24
|
+
export const zCsqSeveritySchema = z.enum(["critica", "alta", "media", "baixa"]);
|
|
25
|
+
|
|
26
|
+
export const zCsqAlertSourceSchema = z.enum(["deterministic", "llm", "hybrid"]);
|
|
27
|
+
|
|
28
|
+
export const zCsqAlertScopeSchema = z.enum(["ticket", "journey"]);
|
|
29
|
+
|
|
30
|
+
export const zCsqAlertLifecycleSchema = z.enum(["open", "resolved"]);
|
|
31
|
+
|
|
32
|
+
export const zCsqVerificationStateSchema = z.enum([
|
|
33
|
+
"pending",
|
|
34
|
+
"confirmed_ok",
|
|
35
|
+
"confirmed",
|
|
36
|
+
"inconclusive",
|
|
37
|
+
]);
|
|
38
|
+
|
|
39
|
+
export const zCsqRunStatusSchema = z.enum([
|
|
40
|
+
"running",
|
|
41
|
+
"done",
|
|
42
|
+
"failed",
|
|
43
|
+
"quarantined",
|
|
44
|
+
]);
|
|
45
|
+
|
|
46
|
+
export const zCsqPhaseSchema = z.enum(["f0", "f1"]);
|
|
47
|
+
|
|
48
|
+
export const zCsqReviewVerdictSchema = z.enum(["agree", "disagree"]);
|
|
49
|
+
|
|
50
|
+
export const zCsqAuthorKindSchema = z.enum([
|
|
51
|
+
"lead",
|
|
52
|
+
"human",
|
|
53
|
+
"automation",
|
|
54
|
+
"hubia",
|
|
55
|
+
"event",
|
|
56
|
+
"note",
|
|
57
|
+
]);
|
|
58
|
+
|
|
59
|
+
/** Escala por criterio: 0 / 50 / 100 / N/A. */
|
|
60
|
+
export const zCsqCriterionScoreValueSchema = z.union([
|
|
61
|
+
z.literal(0),
|
|
62
|
+
z.literal(50),
|
|
63
|
+
z.literal(100),
|
|
64
|
+
z.literal("NA"),
|
|
65
|
+
]);
|
|
66
|
+
|
|
67
|
+
export const zCsqPillarCodeSchema = z.enum([
|
|
68
|
+
"coerencia_historico",
|
|
69
|
+
"roteiro_conversao",
|
|
70
|
+
"acuracidade",
|
|
71
|
+
"responsividade",
|
|
72
|
+
"cordialidade_linguagem",
|
|
73
|
+
]);
|
|
74
|
+
|
|
75
|
+
/** Catalogo de alertas v1 (report-spec §6). Subtipos vao em `subtype`. */
|
|
76
|
+
export const zCsqAlertCodeSchema = z.enum([
|
|
77
|
+
"AGENDAMENTO_INFORMADO_NAO_REGISTRADO",
|
|
78
|
+
"AGENDAMENTO_DIVERGENTE",
|
|
79
|
+
"AGENDAMENTO_SOBREPOSTO",
|
|
80
|
+
"CONTRADICAO_PREMISSA_ANTERIOR",
|
|
81
|
+
"ORIENTACAO_CLINICA_INDEVIDA",
|
|
82
|
+
"POLITICA_VIOLADA",
|
|
83
|
+
"ULTIMA_MENSAGEM_SEM_RESPOSTA",
|
|
84
|
+
"PERGUNTA_NAO_RESPONDIDA",
|
|
85
|
+
"PROMESSA_NAO_CUMPRIDA",
|
|
86
|
+
"IDENTIDADE_ERRADA",
|
|
87
|
+
"DADO_JA_INFORMADO_RECOLETADO",
|
|
88
|
+
"DADO_OBRIGATORIO_NAO_COLETADO",
|
|
89
|
+
"FLUXO_VENDA_NAO_SEGUIDO",
|
|
90
|
+
"MOTIVO_ENCERRAMENTO_INCOMPATIVEL",
|
|
91
|
+
"SLA_RESPOSTA_ALTO",
|
|
92
|
+
"LEAD_QUENTE_SEM_FOLLOWUP",
|
|
93
|
+
"LEAD_ORIGEM_INCONSISTENTE",
|
|
94
|
+
"LEAD_QUALIFICACAO_INCONSISTENTE",
|
|
95
|
+
"AUTOMACAO_CONFLITANTE",
|
|
96
|
+
"DADO_SENSIVEL_SOLICITADO",
|
|
97
|
+
"URGENCIA_NAO_ENCAMINHADA",
|
|
98
|
+
"NF_NAO_ENVIADA",
|
|
99
|
+
"COBRANCA_NAO_ENVIADA",
|
|
100
|
+
]);
|
|
101
|
+
|
|
102
|
+
/** Subtipos de POLITICA_VIOLADA e de FLUXO_VENDA_NAO_SEGUIDO. */
|
|
103
|
+
export const zCsqAlertSubtypeSchema = z.enum([
|
|
104
|
+
"valor",
|
|
105
|
+
"parcelamento",
|
|
106
|
+
"convenio",
|
|
107
|
+
"dia_horario",
|
|
108
|
+
"procedimento",
|
|
109
|
+
"modalidade",
|
|
110
|
+
"objecao_sem_argumento",
|
|
111
|
+
"sem_oferta_concreta",
|
|
112
|
+
"preco_antes_da_queixa",
|
|
113
|
+
]);
|
|
114
|
+
|
|
115
|
+
// ───────── Evidencia ─────────
|
|
116
|
+
|
|
117
|
+
/** `message_id` DEVE existir na transcricao; o codigo descarta invalidos. */
|
|
118
|
+
export const zCsqEvidenceSchema = z.object({
|
|
119
|
+
message_id: z.string(),
|
|
120
|
+
ticket_id: z.string(),
|
|
121
|
+
ts: zFirestoreDateSchema,
|
|
122
|
+
excerpt: z.string(),
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
// ───────── Alertas ─────────
|
|
126
|
+
|
|
127
|
+
export const zCsqAlertSchema = z.object({
|
|
128
|
+
code: zCsqAlertCodeSchema,
|
|
129
|
+
subtype: zCsqAlertSubtypeSchema.optional(),
|
|
130
|
+
severity: zCsqSeveritySchema,
|
|
131
|
+
source: zCsqAlertSourceSchema,
|
|
132
|
+
scope: zCsqAlertScopeSchema,
|
|
133
|
+
status: zCsqAlertLifecycleSchema,
|
|
134
|
+
/** sha1(code|subtype|target|evidence.message_id) — chave de dedupe/lifecycle. */
|
|
135
|
+
fingerprint: z.string(),
|
|
136
|
+
title: z.string(),
|
|
137
|
+
evidence: z.array(zCsqEvidenceSchema),
|
|
138
|
+
suggested_action: z.string().optional(),
|
|
139
|
+
verification: zCsqVerificationStateSchema.optional(),
|
|
140
|
+
recheck_after: zFirestoreDateSchema.optional(),
|
|
141
|
+
resolved_in_ticket: z.string().optional(),
|
|
142
|
+
first_seen_ticket_id: z.string(),
|
|
143
|
+
created_at: zFirestoreDateSchema,
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
// ───────── Indicadores (report-spec §3) ─────────
|
|
147
|
+
|
|
148
|
+
const zNullableNumber = z.number().nullable();
|
|
149
|
+
|
|
150
|
+
export const zCsqIndicatorsSetSchema = z.object({
|
|
151
|
+
frt_min: zNullableNumber,
|
|
152
|
+
art_median_min: zNullableNumber,
|
|
153
|
+
art_p90_min: zNullableNumber,
|
|
154
|
+
max_gap_min: zNullableNumber,
|
|
155
|
+
unanswered_questions: zNullableNumber,
|
|
156
|
+
last_message_unanswered: z.boolean().nullable(),
|
|
157
|
+
time_to_first_offer_min: zNullableNumber,
|
|
158
|
+
time_to_conversion_h: zNullableNumber,
|
|
159
|
+
converted: z.boolean().nullable(),
|
|
160
|
+
messages_in: zNullableNumber,
|
|
161
|
+
messages_out_human: zNullableNumber,
|
|
162
|
+
messages_out_auto: zNullableNumber,
|
|
163
|
+
messages_out_ai: zNullableNumber,
|
|
164
|
+
attendants_distinct: zNullableNumber,
|
|
165
|
+
tickets_count: zNullableNumber,
|
|
166
|
+
reopen_count: zNullableNumber,
|
|
167
|
+
transfer_count: zNullableNumber,
|
|
168
|
+
automation_only_tickets: zNullableNumber,
|
|
169
|
+
audio_in_untranscribed: zNullableNumber,
|
|
170
|
+
silence_days_since_last_inbound: zNullableNumber,
|
|
171
|
+
reactivation_attempts: zNullableNumber,
|
|
172
|
+
/** `true` quando o conjunto usa heuristica da F0. */
|
|
173
|
+
provisional: z.boolean().optional(),
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
export const zCsqIndicatorsSchema = z.object({
|
|
177
|
+
ticket: zCsqIndicatorsSetSchema,
|
|
178
|
+
journey: zCsqIndicatorsSetSchema,
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
// ───────── Estado do lead (report-spec §2.3) ─────────
|
|
182
|
+
|
|
183
|
+
export const zCsqLeadStateFieldSchema = z.object({
|
|
184
|
+
value: z.string().nullable(),
|
|
185
|
+
evidence: z.array(zCsqEvidenceSchema),
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
export const zCsqLeadStateListFieldSchema = z.object({
|
|
189
|
+
value: z.array(z.string()),
|
|
190
|
+
evidence: z.array(zCsqEvidenceSchema),
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
/** Premissas extraidas pelo juiz; entram como contexto do proximo fechamento. */
|
|
194
|
+
export const zCsqLeadStateSchema = z.object({
|
|
195
|
+
speaker_vs_patient: zCsqLeadStateFieldSchema,
|
|
196
|
+
complaint_or_procedure: zCsqLeadStateFieldSchema,
|
|
197
|
+
preferred_professional: zCsqLeadStateFieldSchema,
|
|
198
|
+
patient_status: zCsqLeadStateFieldSchema,
|
|
199
|
+
insurance: zCsqLeadStateFieldSchema,
|
|
200
|
+
constraints: zCsqLeadStateListFieldSchema,
|
|
201
|
+
price_informed: zCsqLeadStateFieldSchema,
|
|
202
|
+
appointment_informed: zCsqLeadStateFieldSchema,
|
|
203
|
+
promises: zCsqLeadStateListFieldSchema,
|
|
204
|
+
open_questions: zCsqLeadStateListFieldSchema,
|
|
205
|
+
objections: zCsqLeadStateListFieldSchema,
|
|
206
|
+
required_data_collected: zCsqLeadStateListFieldSchema,
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
// ───────── Claims (report-spec §5) ─────────
|
|
210
|
+
|
|
211
|
+
export const zCsqClaimAppointmentInformedSchema = z.object({
|
|
212
|
+
type: z.literal("appointment_informed"),
|
|
213
|
+
/** YYYY-MM-DD na TZ do tenant. */
|
|
214
|
+
date: z.string(),
|
|
215
|
+
/** HH:mm, quando houve. */
|
|
216
|
+
time: z.string().optional(),
|
|
217
|
+
professional: z.string().optional(),
|
|
218
|
+
modality: z.string().optional(),
|
|
219
|
+
evidence: z.array(zCsqEvidenceSchema),
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
export const zCsqClaimPromiseSchema = z.object({
|
|
223
|
+
type: z.literal("promise"),
|
|
224
|
+
what: z.string(),
|
|
225
|
+
due: z.string().optional(),
|
|
226
|
+
evidence: z.array(zCsqEvidenceSchema),
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
export const zCsqClaimDataCollectedSchema = z.object({
|
|
230
|
+
type: z.literal("data_collected"),
|
|
231
|
+
fields: z.array(z.string()),
|
|
232
|
+
evidence: z.array(zCsqEvidenceSchema),
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
export const zCsqClaimRequiredDataSchema = z.object({
|
|
236
|
+
type: z.literal("required_data"),
|
|
237
|
+
fields: z.array(z.string()),
|
|
238
|
+
evidence: z.array(zCsqEvidenceSchema),
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
export const zCsqClaimOutcomeSchema = z.object({
|
|
242
|
+
type: z.literal("outcome"),
|
|
243
|
+
outcome: z.string(),
|
|
244
|
+
expected_close_code: z.string().optional(),
|
|
245
|
+
evidence: z.array(zCsqEvidenceSchema),
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
export const zCsqClaimQuestionRequiresAnswerSchema = z.object({
|
|
249
|
+
type: z.literal("question_requires_answer"),
|
|
250
|
+
message_id: z.string(),
|
|
251
|
+
question: z.string(),
|
|
252
|
+
evidence: z.array(zCsqEvidenceSchema),
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
export const zCsqClaimFirstConcreteOfferSchema = z.object({
|
|
256
|
+
type: z.literal("first_concrete_offer"),
|
|
257
|
+
message_id: z.string(),
|
|
258
|
+
evidence: z.array(zCsqEvidenceSchema),
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
export const zCsqClaimPatientStatusSchema = z.object({
|
|
262
|
+
type: z.literal("patient_status"),
|
|
263
|
+
status: z.enum(["first_visit", "existing_patient", "unknown"]),
|
|
264
|
+
evidence: z.array(zCsqEvidenceSchema),
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
export const zCsqClaimPriceInformedSchema = z.object({
|
|
268
|
+
type: z.literal("price_informed"),
|
|
269
|
+
amount: z.string().optional(),
|
|
270
|
+
payment_method: z.string().optional(),
|
|
271
|
+
installments: z.string().optional(),
|
|
272
|
+
includes: z.string().optional(),
|
|
273
|
+
evidence: z.array(zCsqEvidenceSchema),
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
/** O juiz extrai, o codigo verifica (report-spec §5). */
|
|
277
|
+
export const zCsqClaimSchema = z.discriminatedUnion("type", [
|
|
278
|
+
zCsqClaimAppointmentInformedSchema,
|
|
279
|
+
zCsqClaimPromiseSchema,
|
|
280
|
+
zCsqClaimDataCollectedSchema,
|
|
281
|
+
zCsqClaimRequiredDataSchema,
|
|
282
|
+
zCsqClaimOutcomeSchema,
|
|
283
|
+
zCsqClaimQuestionRequiresAnswerSchema,
|
|
284
|
+
zCsqClaimFirstConcreteOfferSchema,
|
|
285
|
+
zCsqClaimPatientStatusSchema,
|
|
286
|
+
zCsqClaimPriceInformedSchema,
|
|
287
|
+
]);
|
|
288
|
+
|
|
289
|
+
export const zCsqClaimTypeSchema = z.enum([
|
|
290
|
+
"appointment_informed",
|
|
291
|
+
"promise",
|
|
292
|
+
"data_collected",
|
|
293
|
+
"required_data",
|
|
294
|
+
"outcome",
|
|
295
|
+
"question_requires_answer",
|
|
296
|
+
"first_concrete_offer",
|
|
297
|
+
"patient_status",
|
|
298
|
+
"price_informed",
|
|
299
|
+
]);
|
|
300
|
+
|
|
301
|
+
/** Linha da tabela "o que foi dito x o que consta" (report-spec §2.5). */
|
|
302
|
+
export const zCsqCrossCheckSchema = z.object({
|
|
303
|
+
claim_type: zCsqClaimTypeSchema,
|
|
304
|
+
result: z.enum(["match", "mismatch", "missing", "inconclusive"]),
|
|
305
|
+
expected: z.string(),
|
|
306
|
+
found: z.string().nullable(),
|
|
307
|
+
alert_code: zCsqAlertCodeSchema.optional(),
|
|
308
|
+
note: z.string().optional(),
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
// ───────── Avaliacao (report-spec §4) ─────────
|
|
312
|
+
|
|
313
|
+
export const zCsqCriterionScoreSchema = z.object({
|
|
314
|
+
pillar: zCsqPillarCodeSchema,
|
|
315
|
+
criterion: z.string(),
|
|
316
|
+
score: zCsqCriterionScoreValueSchema,
|
|
317
|
+
evidence: z.array(zCsqEvidenceSchema),
|
|
318
|
+
note: z.string().optional(),
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
export const zCsqPillarCoverageSchema = z.object({
|
|
322
|
+
scored: z.number(),
|
|
323
|
+
total: z.number(),
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
export const zCsqPillarScoreSchema = z.object({
|
|
327
|
+
pillar: zCsqPillarCodeSchema,
|
|
328
|
+
score: z.number().nullable(),
|
|
329
|
+
coverage: zCsqPillarCoverageSchema,
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
/** `score` = jornada; `ticket_score` = so evidencias do ticket fechado (Q11=A). */
|
|
333
|
+
export const zCsqEvaluationSchema = z.object({
|
|
334
|
+
pillars: z.array(zCsqPillarScoreSchema),
|
|
335
|
+
score: z.number().nullable(),
|
|
336
|
+
ticket_score: z.number().nullable(),
|
|
337
|
+
status: zCsqStatusSchema,
|
|
338
|
+
auto_fail: z.array(zCsqAlertCodeSchema),
|
|
339
|
+
escalate: z.object({
|
|
340
|
+
value: z.boolean(),
|
|
341
|
+
reasons: z.array(z.string()),
|
|
342
|
+
}),
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
// ───────── Atribuicao, cobertura, veredito ─────────
|
|
346
|
+
|
|
347
|
+
export const zCsqContributorSchema = z.object({
|
|
348
|
+
user_id: z.string(),
|
|
349
|
+
name: z.string(),
|
|
350
|
+
messages_in_ticket: z.number(),
|
|
351
|
+
messages_in_journey: z.number(),
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
export const zCsqCoverageSchema = z.object({
|
|
355
|
+
threads: z.enum(["single", "all"]),
|
|
356
|
+
tickets_covered: z.number(),
|
|
357
|
+
tickets_total: z.number(),
|
|
358
|
+
messages_truncated: z.number(),
|
|
359
|
+
criteria_scored_by_pillar: z.record(zCsqPillarCoverageSchema),
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
export const zCsqDataQualitySchema = z
|
|
363
|
+
.object({
|
|
364
|
+
missing_business_hours: z.boolean().optional(),
|
|
365
|
+
missing_prompt_stack: z.boolean().optional(),
|
|
366
|
+
missing_calendar: z.boolean().optional(),
|
|
367
|
+
})
|
|
368
|
+
.passthrough();
|
|
369
|
+
|
|
370
|
+
export const zCsqReviewSchema = z.object({
|
|
371
|
+
verdict: zCsqReviewVerdictSchema,
|
|
372
|
+
false_alert_fingerprints: z.array(z.string()),
|
|
373
|
+
note: z.string().optional(),
|
|
374
|
+
reviewer_login_id: z.string(),
|
|
375
|
+
reviewed_at: zFirestoreDateSchema,
|
|
376
|
+
});
|
|
377
|
+
|
|
378
|
+
// ───────── Trilha e denormalizacao ─────────
|
|
379
|
+
|
|
380
|
+
export const zCsqTrailEntrySchema = z.object({
|
|
381
|
+
ticket_id: z.string(),
|
|
382
|
+
closed_at: zFirestoreDateSchema,
|
|
383
|
+
evaluated_at: zFirestoreDateSchema,
|
|
384
|
+
score: z.number().nullable(),
|
|
385
|
+
status: zCsqStatusSchema,
|
|
386
|
+
alerts_critical: z.number(),
|
|
387
|
+
alerts_new: z.number(),
|
|
388
|
+
alerts_resolved: z.number(),
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
/** Resumo denormalizado gravado em `ticket.csq`. */
|
|
392
|
+
export const zCsqTicketSummarySchema = z.object({
|
|
393
|
+
score: z.number().nullable(),
|
|
394
|
+
status: zCsqStatusSchema,
|
|
395
|
+
alerts_critical_open: z.number(),
|
|
396
|
+
evaluated_at: zFirestoreDateSchema,
|
|
397
|
+
rubric_version: z.string(),
|
|
398
|
+
lead_id: z.string(),
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
// ───────── Transcricao ─────────
|
|
402
|
+
|
|
403
|
+
export const zCsqTranscriptMessageSchema = z.object({
|
|
404
|
+
message_id: z.string(),
|
|
405
|
+
ticket_id: z.string(),
|
|
406
|
+
ts: zFirestoreDateSchema,
|
|
407
|
+
author_kind: zCsqAuthorKindSchema,
|
|
408
|
+
author_label: z.string(),
|
|
409
|
+
type: z.string(),
|
|
410
|
+
text: z.string(),
|
|
411
|
+
unattributed: z.boolean().optional(),
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
// ───────── Saida do juiz ─────────
|
|
415
|
+
|
|
416
|
+
export const zCsqLlmUsageSchema = z.object({
|
|
417
|
+
input_tokens: z.number(),
|
|
418
|
+
output_tokens: z.number(),
|
|
419
|
+
cache_read_tokens: z.number().optional(),
|
|
420
|
+
cache_creation_tokens: z.number().optional(),
|
|
421
|
+
rounds: z.number().optional(),
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
/** Schema da tool `submit_csq_evaluation`. ESTRITO de proposito: e o contrato
|
|
425
|
+
* de saida do LLM, nao um doc do Firestore — nada de passthrough aqui. */
|
|
426
|
+
export const zCsqJudgeOutputSchema = z.object({
|
|
427
|
+
summary: z.string(),
|
|
428
|
+
lead_state: zCsqLeadStateSchema,
|
|
429
|
+
claims: z.array(zCsqClaimSchema),
|
|
430
|
+
criteria: z.array(zCsqCriterionScoreSchema),
|
|
431
|
+
/** So alertas de fonte `llm` ou `hybrid`. */
|
|
432
|
+
alerts: z.array(zCsqAlertSchema),
|
|
433
|
+
/** Fingerprints de alertas anteriores resolvidos neste atendimento. */
|
|
434
|
+
resolved_alert_ids: z.array(z.string()),
|
|
435
|
+
highlights: z.array(z.string()),
|
|
436
|
+
improvements: z.array(z.string()),
|
|
437
|
+
confidence: z.number().min(0).max(1),
|
|
438
|
+
notes: z.string().optional(),
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
// ───────── Fatos do sistema (report-spec §2.4) ─────────
|
|
442
|
+
|
|
443
|
+
export const zCsqAppointmentFactSchema = z.object({
|
|
444
|
+
id: z.string(),
|
|
445
|
+
calendar_id: z.string(),
|
|
446
|
+
patient_id: z.string().optional(),
|
|
447
|
+
start_at: zFirestoreDateSchema,
|
|
448
|
+
end_at: zFirestoreDateSchema.optional(),
|
|
449
|
+
status: z.string().optional(),
|
|
450
|
+
status_base: z.string().optional(),
|
|
451
|
+
professional_name: z.string().optional(),
|
|
452
|
+
modality: z.string().optional(),
|
|
453
|
+
created_at: zFirestoreDateSchema.optional(),
|
|
454
|
+
});
|
|
455
|
+
|
|
456
|
+
export const zCsqOverlapFactSchema = z.object({
|
|
457
|
+
professional_name: z.string().optional(),
|
|
458
|
+
appointment_ids: z.array(z.string()),
|
|
459
|
+
start_at: zFirestoreDateSchema,
|
|
460
|
+
end_at: zFirestoreDateSchema,
|
|
461
|
+
});
|
|
462
|
+
|
|
463
|
+
export const zCsqPreviousTicketFactSchema = z.object({
|
|
464
|
+
ticket_id: z.string(),
|
|
465
|
+
closed_at: zFirestoreDateSchema.optional(),
|
|
466
|
+
close_code: z.string().optional(),
|
|
467
|
+
close_name: z.string().optional(),
|
|
468
|
+
closed_by_name: z.string().optional(),
|
|
469
|
+
messages_count: z.number().optional(),
|
|
470
|
+
});
|
|
471
|
+
|
|
472
|
+
export const zCsqBillingFactSchema = z.object({
|
|
473
|
+
id: z.string(),
|
|
474
|
+
kind: z.enum(["invoice", "payment_link"]),
|
|
475
|
+
appointment_id: z.string().optional(),
|
|
476
|
+
status: z.string().optional(),
|
|
477
|
+
sent: z.boolean().optional(),
|
|
478
|
+
sent_at: zFirestoreDateSchema.optional(),
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
export const zCsqSystemFactsSchema = z.object({
|
|
482
|
+
appointments: z.array(zCsqAppointmentFactSchema),
|
|
483
|
+
overlaps: z.array(zCsqOverlapFactSchema),
|
|
484
|
+
tags: z.array(z.string()),
|
|
485
|
+
qualification: z.string().nullable(),
|
|
486
|
+
dist_channel: z.string().nullable(),
|
|
487
|
+
capture_data: z.record(z.unknown()).nullable(),
|
|
488
|
+
invoices: z.array(zCsqBillingFactSchema),
|
|
489
|
+
payment_links: z.array(zCsqBillingFactSchema),
|
|
490
|
+
previous_tickets: z.array(zCsqPreviousTicketFactSchema),
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
// ───────── Cabecalho do laudo (report-spec §2.1) ─────────
|
|
494
|
+
|
|
495
|
+
export const zCsqReportLeadSchema = z.object({
|
|
496
|
+
name: z.string().nullable(),
|
|
497
|
+
/** Mascarado na projecao da fila do Nexus (adendo §F). */
|
|
498
|
+
phone: z.string().nullable(),
|
|
499
|
+
});
|
|
500
|
+
|
|
501
|
+
export const zCsqReportPatientSchema = z.object({
|
|
502
|
+
id: z.string(),
|
|
503
|
+
name: z.string().nullable(),
|
|
504
|
+
});
|
|
505
|
+
|
|
506
|
+
export const zCsqReportAttendantSchema = z.object({
|
|
507
|
+
user_id: z.string(),
|
|
508
|
+
name: z.string().nullable(),
|
|
509
|
+
});
|
|
510
|
+
|
|
511
|
+
export const zCsqReportHeaderSchema = z.object({
|
|
512
|
+
lead: zCsqReportLeadSchema,
|
|
513
|
+
patients: z.array(zCsqReportPatientSchema),
|
|
514
|
+
attendants: z.array(zCsqReportAttendantSchema),
|
|
515
|
+
period: z.object({
|
|
516
|
+
from: zFirestoreDateSchema.nullable(),
|
|
517
|
+
to: zFirestoreDateSchema.nullable(),
|
|
518
|
+
}),
|
|
519
|
+
tickets_count: z.number(),
|
|
520
|
+
});
|
|
521
|
+
|
|
522
|
+
export const zCsqEvaluatedForSchema = z.object({
|
|
523
|
+
ticket_id: z.string(),
|
|
524
|
+
closed_at: zFirestoreDateSchema,
|
|
525
|
+
close: z.object({
|
|
526
|
+
code: z.string().nullable().optional(),
|
|
527
|
+
name: z.string().nullable().optional(),
|
|
528
|
+
type_code: z.string().nullable().optional(),
|
|
529
|
+
notes: z.string().nullable().optional(),
|
|
530
|
+
}),
|
|
531
|
+
closed_by_user_id: z.string().nullable(),
|
|
532
|
+
closed_by_name: z.string().nullable(),
|
|
533
|
+
});
|
|
534
|
+
|
|
535
|
+
export const zCsqEligibilitySchema = z.object({
|
|
536
|
+
csq_mode: zCsqModeSchema,
|
|
537
|
+
eligible_calendar_ids: z.array(z.string()),
|
|
538
|
+
has_human_message: z.boolean(),
|
|
539
|
+
reason: z.string().optional(),
|
|
540
|
+
});
|
|
541
|
+
|
|
542
|
+
export const zCsqAlertCountsSchema = z.object({
|
|
543
|
+
alerts_open: z.number(),
|
|
544
|
+
alerts_critical_open: z.number(),
|
|
545
|
+
alerts_new: z.number(),
|
|
546
|
+
alerts_resolved: z.number(),
|
|
547
|
+
});
|
|
548
|
+
|
|
549
|
+
// ───────── Ledger de execucao (adendo §A) ─────────
|
|
550
|
+
|
|
551
|
+
/** `tenants/{t}/apps/evo-csq/runs/{eventId}`. */
|
|
552
|
+
export const zCsqRunSchema = zFireDocSchema
|
|
553
|
+
.extend({
|
|
554
|
+
event_id: z.string(),
|
|
555
|
+
status: zCsqRunStatusSchema,
|
|
556
|
+
attempts: z.number().default(0),
|
|
557
|
+
started_at: zFirestoreDateSchema,
|
|
558
|
+
finished_at: zFirestoreDateSchema.optional(),
|
|
559
|
+
error: z.string().optional(),
|
|
560
|
+
phase: zCsqPhaseSchema,
|
|
561
|
+
evaluation_id: z.string().optional(),
|
|
562
|
+
bq_pending: z.boolean().optional(),
|
|
563
|
+
/** TTL do Firestore (+30 dias). */
|
|
564
|
+
expires_at: zFirestoreDateSchema,
|
|
565
|
+
})
|
|
566
|
+
.passthrough();
|
|
567
|
+
|
|
568
|
+
// ───────── Laudo corrente por lead ─────────
|
|
569
|
+
|
|
570
|
+
/** `tenants/{t}/apps/evo-csq/lead-reports/{leadId}` — laudo corrente,
|
|
571
|
+
* sobrescrito a cada fechamento humano elegivel. */
|
|
572
|
+
export const zCsqLeadReportSchema = zFireDocSchema
|
|
573
|
+
.extend({
|
|
574
|
+
model_ver: z.number().default(1),
|
|
575
|
+
lead_id: z.string(),
|
|
576
|
+
contact_id: z.string(),
|
|
577
|
+
thread_id: z.string(),
|
|
578
|
+
department_id: z.string(),
|
|
579
|
+
department_name: z.string().nullable(),
|
|
580
|
+
channel_id: z.string().nullable(),
|
|
581
|
+
phase: zCsqPhaseSchema,
|
|
582
|
+
rubric_version: z.string(),
|
|
583
|
+
model: z.string().nullable(),
|
|
584
|
+
prompt_version: z.string().nullable(),
|
|
585
|
+
evaluated_at: zFirestoreDateSchema,
|
|
586
|
+
/** Ultimo `event_id` processado — corta redelivery do Pub/Sub. */
|
|
587
|
+
last_event_key: z.string(),
|
|
588
|
+
evaluation_id: z.string(),
|
|
589
|
+
version: z.number().default(1),
|
|
590
|
+
|
|
591
|
+
evaluated_for: zCsqEvaluatedForSchema,
|
|
592
|
+
header: zCsqReportHeaderSchema,
|
|
593
|
+
eligibility: zCsqEligibilitySchema,
|
|
594
|
+
indicators: zCsqIndicatorsSchema,
|
|
595
|
+
system_facts: zCsqSystemFactsSchema,
|
|
596
|
+
|
|
597
|
+
summary: z.string().nullable(),
|
|
598
|
+
lead_state: zCsqLeadStateSchema.nullable(),
|
|
599
|
+
claims: z.array(zCsqClaimSchema),
|
|
600
|
+
cross_checks: z.array(zCsqCrossCheckSchema),
|
|
601
|
+
criteria: z.array(zCsqCriterionScoreSchema).optional(),
|
|
602
|
+
evaluation: zCsqEvaluationSchema,
|
|
603
|
+
alerts: z.array(zCsqAlertSchema),
|
|
604
|
+
counts: zCsqAlertCountsSchema,
|
|
605
|
+
/** Espelho de `counts.alerts_critical_open > 0` (campo para indice). */
|
|
606
|
+
has_critical_open: z.boolean(),
|
|
607
|
+
|
|
608
|
+
highlights: z.array(z.string()),
|
|
609
|
+
improvements: z.array(z.string()),
|
|
610
|
+
confidence: z.number(),
|
|
611
|
+
|
|
612
|
+
contributors: z.array(zCsqContributorSchema),
|
|
613
|
+
primary_agent_id: z.string().nullable(),
|
|
614
|
+
coverage: zCsqCoverageSchema,
|
|
615
|
+
data_quality: zCsqDataQualitySchema.optional(),
|
|
616
|
+
review: zCsqReviewSchema.optional(),
|
|
617
|
+
verification: zCsqVerificationStateSchema.optional(),
|
|
618
|
+
|
|
619
|
+
policy_snapshot_hash: z.string().nullable(),
|
|
620
|
+
dictionary_snapshot_hash: z.string().nullable(),
|
|
621
|
+
|
|
622
|
+
llm_usage: zCsqLlmUsageSchema.nullable(),
|
|
623
|
+
cost_usd_est: z.number().nullable(),
|
|
624
|
+
trail: z.array(zCsqTrailEntrySchema),
|
|
625
|
+
judge_error: z.string().optional(),
|
|
626
|
+
})
|
|
627
|
+
.passthrough();
|
|
@@ -12921,6 +12921,7 @@ export declare const zNexVendasJourneyPaymentSchema: z.ZodObject<{
|
|
|
12921
12921
|
created_at?: Date | null | undefined;
|
|
12922
12922
|
kind?: "payment_link" | "boleto" | "asaas_checkout" | null | undefined;
|
|
12923
12923
|
last_error?: string | null | undefined;
|
|
12924
|
+
expires_at?: Date | null | undefined;
|
|
12924
12925
|
boleto?: {
|
|
12925
12926
|
value?: number | null | undefined;
|
|
12926
12927
|
payment_id?: string | null | undefined;
|
|
@@ -12931,7 +12932,6 @@ export declare const zNexVendasJourneyPaymentSchema: z.ZodObject<{
|
|
|
12931
12932
|
due_date?: string | null | undefined;
|
|
12932
12933
|
} | null | undefined;
|
|
12933
12934
|
paid_at?: Date | null | undefined;
|
|
12934
|
-
expires_at?: Date | null | undefined;
|
|
12935
12935
|
subscription_id?: string | null | undefined;
|
|
12936
12936
|
checkout_id?: string | null | undefined;
|
|
12937
12937
|
payment_link_id?: string | null | undefined;
|
|
@@ -12960,6 +12960,7 @@ export declare const zNexVendasJourneyPaymentSchema: z.ZodObject<{
|
|
|
12960
12960
|
created_at?: unknown;
|
|
12961
12961
|
kind?: "payment_link" | "boleto" | "asaas_checkout" | null | undefined;
|
|
12962
12962
|
last_error?: string | null | undefined;
|
|
12963
|
+
expires_at?: unknown;
|
|
12963
12964
|
boleto?: {
|
|
12964
12965
|
value?: number | null | undefined;
|
|
12965
12966
|
payment_id?: string | null | undefined;
|
|
@@ -12970,7 +12971,6 @@ export declare const zNexVendasJourneyPaymentSchema: z.ZodObject<{
|
|
|
12970
12971
|
due_date?: string | null | undefined;
|
|
12971
12972
|
} | null | undefined;
|
|
12972
12973
|
paid_at?: unknown;
|
|
12973
|
-
expires_at?: unknown;
|
|
12974
12974
|
subscription_id?: string | null | undefined;
|
|
12975
12975
|
checkout_id?: string | null | undefined;
|
|
12976
12976
|
payment_link_id?: string | null | undefined;
|