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