evo360-types 1.3.764 → 1.3.766
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-docs/zod-schemas.d.ts +3260 -0
- package/dist/apps/evo-docs/zod-schemas.js +258 -0
- package/dist/apps/evo-docs/zod-schemas.ts +299 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.ts +2 -0
- package/dist/types/evo-docs/fb_collections.d.ts +2 -0
- package/dist/types/evo-docs/fb_collections.js +9 -0
- package/dist/types/evo-docs/fb_collections.ts +7 -0
- package/dist/types/evo-docs/index.d.ts +291 -0
- package/dist/types/evo-docs/index.js +125 -0
- package/dist/types/evo-docs/index.ts +385 -0
- package/package.json +1 -1
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
import type { ExternalObjectType, IExternalLink, IExternalLinkRelation, IFireDoc, ITag } from "../shared";
|
|
2
|
+
import type { MessageDirection } from "../evo-chat/thread-message";
|
|
3
|
+
import type { PatientAttachmentBaseCategory } from "../evo-med/dic";
|
|
4
|
+
export * from "./fb_collections";
|
|
5
|
+
/** De onde o anexo veio. Fonte A = upload da ficha; B = chat; C = e-mail. */
|
|
6
|
+
export declare const AttachmentSourceKindEnum: {
|
|
7
|
+
readonly PatientUpload: "patient_upload";
|
|
8
|
+
readonly AppointmentUpload: "appointment_upload";
|
|
9
|
+
readonly ChatMessage: "chat_message";
|
|
10
|
+
readonly EmailMessage: "email_message";
|
|
11
|
+
/** Reservado, sem escritor na v1 (D5: entra num 2º momento). */
|
|
12
|
+
readonly HistoryImport: "history_import";
|
|
13
|
+
/** Reservado, sem escritor na v1. */
|
|
14
|
+
readonly PlatformGenerated: "platform_generated";
|
|
15
|
+
};
|
|
16
|
+
export type AttachmentSourceKind = (typeof AttachmentSourceKindEnum)[keyof typeof AttachmentSourceKindEnum];
|
|
17
|
+
/** Fontes que são troca de mensagem: nelas `source.direction` é obrigatório (Q9). */
|
|
18
|
+
export declare const ATTACHMENT_MESSAGE_SOURCE_KINDS: readonly ["chat_message", "email_message"];
|
|
19
|
+
/** Recebido × enviado pela clínica (Q9). `null` em upload da ficha. */
|
|
20
|
+
export declare const AttachmentDirectionEnum: {
|
|
21
|
+
readonly Inbound: "inbound";
|
|
22
|
+
readonly Outbound: "outbound";
|
|
23
|
+
};
|
|
24
|
+
export type AttachmentDirection = (typeof AttachmentDirectionEnum)[keyof typeof AttachmentDirectionEnum];
|
|
25
|
+
/** Quem decidiu a categoria vigente. Humano nunca é sobrescrito pela IA. */
|
|
26
|
+
export declare const AttachmentClassificationSourceEnum: {
|
|
27
|
+
readonly Human: "human";
|
|
28
|
+
readonly Hubia: "hubia";
|
|
29
|
+
readonly None: "none";
|
|
30
|
+
};
|
|
31
|
+
export type AttachmentClassificationSource = (typeof AttachmentClassificationSourceEnum)[keyof typeof AttachmentClassificationSourceEnum];
|
|
32
|
+
export declare const AttachmentMediaKindEnum: {
|
|
33
|
+
readonly Image: "image";
|
|
34
|
+
readonly Document: "document";
|
|
35
|
+
readonly Audio: "audio";
|
|
36
|
+
readonly Video: "video";
|
|
37
|
+
readonly Other: "other";
|
|
38
|
+
};
|
|
39
|
+
export type AttachmentMediaKind = (typeof AttachmentMediaKindEnum)[keyof typeof AttachmentMediaKindEnum];
|
|
40
|
+
/** Tipos de sujeito aceitos em `externalLinks` do anexo (subconjunto de ExternalObjectTypeEnum). */
|
|
41
|
+
export declare const ATTACHMENT_SUBJECT_TYPES: readonly ["med_patient", "crm_lead", "med_appointment", "chat_contact"];
|
|
42
|
+
export type AttachmentSubjectType = (typeof ATTACHMENT_SUBJECT_TYPES)[number];
|
|
43
|
+
/** Raízes aceitas em `GET /attachments?subject=type:id` (§2.6). `chat_contact` não é raiz. */
|
|
44
|
+
export declare const ATTACHMENT_LIST_ROOT_TYPES: readonly ["med_patient", "crm_lead", "med_appointment"];
|
|
45
|
+
export type AttachmentListRootType = (typeof ATTACHMENT_LIST_ROOT_TYPES)[number];
|
|
46
|
+
export declare function isAttachmentSubjectType(type: unknown): type is AttachmentSubjectType;
|
|
47
|
+
/** Chave de `externalLinkKeys`: `"type:id"`. */
|
|
48
|
+
export declare function attachmentSubjectKey(type: ExternalObjectType | string, id: string): string;
|
|
49
|
+
/** Snapshot de quem agiu (padrão de `IPatientAttachment.uploadedBy`), servido em JSON. */
|
|
50
|
+
export interface IAttachmentActor {
|
|
51
|
+
userId: string;
|
|
52
|
+
displayName: string;
|
|
53
|
+
}
|
|
54
|
+
export interface IAttachmentSource {
|
|
55
|
+
kind: AttachmentSourceKind;
|
|
56
|
+
/** Valores conhecidos: 'hub-waba' | 'hub-instagram' | 'amazon-ses' | 'smtp' | 'evo-med'. Não é enum fechado. */
|
|
57
|
+
provider?: string | null;
|
|
58
|
+
channel_id?: string | null;
|
|
59
|
+
/** 'whatsapp' | 'instagram' | 'email'. */
|
|
60
|
+
channel_type?: string | null;
|
|
61
|
+
department_id?: string | null;
|
|
62
|
+
/** A mensagem mora em threads/{thread_id}/messages/{message_id}. */
|
|
63
|
+
thread_id?: string | null;
|
|
64
|
+
message_id?: string | null;
|
|
65
|
+
ticket_id?: string | null;
|
|
66
|
+
/** Posição no `attachments[]` do e-mail; 0 para `media`. */
|
|
67
|
+
message_index?: number | null;
|
|
68
|
+
/** Obrigatório em chat/e-mail (Q9); null em upload da ficha. */
|
|
69
|
+
direction?: AttachmentDirection | null;
|
|
70
|
+
email?: {
|
|
71
|
+
subject?: string | null;
|
|
72
|
+
from?: string | null;
|
|
73
|
+
} | null;
|
|
74
|
+
/** Operador (outbound humano) ou quem subiu na ficha. */
|
|
75
|
+
uploaded_by?: IAttachmentActor | null;
|
|
76
|
+
/** Ordenação da listagem. */
|
|
77
|
+
occurred_at: Date;
|
|
78
|
+
}
|
|
79
|
+
export interface IAttachmentFile {
|
|
80
|
+
/** Ausente quando `blocked` (só `quarantine_uri`). */
|
|
81
|
+
gcs_uri?: string | null;
|
|
82
|
+
filename: string;
|
|
83
|
+
original_filename?: string | null;
|
|
84
|
+
content_type: string;
|
|
85
|
+
size_bytes?: number | null;
|
|
86
|
+
/** Dedupe; null quando a fonte não fornece. */
|
|
87
|
+
sha256?: string | null;
|
|
88
|
+
blocked?: boolean;
|
|
89
|
+
blocked_reason?: string | null;
|
|
90
|
+
quarantine_uri?: string | null;
|
|
91
|
+
media_kind: AttachmentMediaKind;
|
|
92
|
+
caption?: string | null;
|
|
93
|
+
}
|
|
94
|
+
export interface IAttachmentAiSuggestion {
|
|
95
|
+
/** Vocabulário do classificador (`ATTACHMENT_KINDS` do @evo/hubia). */
|
|
96
|
+
kind: string;
|
|
97
|
+
label?: string | null;
|
|
98
|
+
summary: string;
|
|
99
|
+
confidence: number;
|
|
100
|
+
prompt_version: string;
|
|
101
|
+
suggested_base_category: PatientAttachmentBaseCategory | null;
|
|
102
|
+
classified_at: Date;
|
|
103
|
+
}
|
|
104
|
+
export interface IAttachmentClassification {
|
|
105
|
+
/** Snapshot do `display_name` do dicionário `attachment_categories` (feat-021). */
|
|
106
|
+
category?: string | null;
|
|
107
|
+
base_category?: PatientAttachmentBaseCategory | null;
|
|
108
|
+
category_color?: string | null;
|
|
109
|
+
source: AttachmentClassificationSource;
|
|
110
|
+
reviewed_by?: IAttachmentActor | null;
|
|
111
|
+
reviewed_at?: Date | null;
|
|
112
|
+
ai?: IAttachmentAiSuggestion | null;
|
|
113
|
+
}
|
|
114
|
+
export interface IAttachmentLegacy {
|
|
115
|
+
patient_id: string;
|
|
116
|
+
migrated_at: Date;
|
|
117
|
+
}
|
|
118
|
+
/** Anexo unificado: tenants/{t}/apps/evo-docs/attachments/{id}. Escrita só pelo backend. */
|
|
119
|
+
export interface IAttachment extends IFireDoc {
|
|
120
|
+
externalLinks: IExternalLink[];
|
|
121
|
+
/** "type:id", derivado pelo model (nunca vem do cliente). */
|
|
122
|
+
externalLinkKeys: string[];
|
|
123
|
+
primary_subject: {
|
|
124
|
+
type: AttachmentSubjectType;
|
|
125
|
+
id: string;
|
|
126
|
+
};
|
|
127
|
+
source: IAttachmentSource;
|
|
128
|
+
file: IAttachmentFile;
|
|
129
|
+
classification: IAttachmentClassification;
|
|
130
|
+
/** Mesmo shape das tags do lead (`ITag`), não `string[]`. */
|
|
131
|
+
tags?: ITag[] | null;
|
|
132
|
+
description?: string | null;
|
|
133
|
+
/** Fonte A migrada do array (Q7): auditoria da migração lazy. */
|
|
134
|
+
legacy?: IAttachmentLegacy | null;
|
|
135
|
+
created_by?: IAttachmentActor | null;
|
|
136
|
+
}
|
|
137
|
+
/** Motivo da publicação: mensagem persistida ou republicação manual (`POST /attachments/reindex`). */
|
|
138
|
+
export declare const AttachmentIndexReasonEnum: {
|
|
139
|
+
readonly Message: "message";
|
|
140
|
+
readonly Reindex: "reindex";
|
|
141
|
+
};
|
|
142
|
+
export type AttachmentIndexReason = (typeof AttachmentIndexReasonEnum)[keyof typeof AttachmentIndexReasonEnum];
|
|
143
|
+
/**
|
|
144
|
+
* Payload do tópico `app_evo-docs_attachments_index`. Só ids e o contexto que o ponto de
|
|
145
|
+
* publish já tem em memória; nenhum campo do arquivo (o consumidor relê a mensagem).
|
|
146
|
+
*/
|
|
147
|
+
export interface IAttachmentIndexEvent {
|
|
148
|
+
tenant: string;
|
|
149
|
+
thread_id: string;
|
|
150
|
+
message_id: string;
|
|
151
|
+
direction: MessageDirection;
|
|
152
|
+
provider: string;
|
|
153
|
+
channel_id: string;
|
|
154
|
+
channel_type: string;
|
|
155
|
+
ticket_id?: string | null;
|
|
156
|
+
department_id?: string | null;
|
|
157
|
+
lead_id?: string | null;
|
|
158
|
+
/** Links da notificação (ponto 6); o consumidor filtra para `ATTACHMENT_SUBJECT_TYPES`. */
|
|
159
|
+
external_links?: IExternalLink[] | null;
|
|
160
|
+
created_by?: IAttachmentActor | null;
|
|
161
|
+
occurred_at: Date;
|
|
162
|
+
trace_id?: string | null;
|
|
163
|
+
/** Default `message`. */
|
|
164
|
+
reason?: AttachmentIndexReason;
|
|
165
|
+
}
|
|
166
|
+
/** Atributos Pub/Sub da mensagem do evento (sempre string). */
|
|
167
|
+
export interface IAttachmentIndexEventAttributes {
|
|
168
|
+
tenant: string;
|
|
169
|
+
direction: MessageDirection;
|
|
170
|
+
trace_id?: string;
|
|
171
|
+
}
|
|
172
|
+
/** Confiança mínima para a sugestão da HubIA virar categoria (D4; mesma do classificador). */
|
|
173
|
+
export declare const ATTACHMENT_APPLY_MIN_CONFIDENCE = 0.7;
|
|
174
|
+
/**
|
|
175
|
+
* `kind` do classificador da HubIA → categoria base da feat-021. `unreadable` não sugere.
|
|
176
|
+
* `skipped` é do use case (não é kind do modelo) e não grava `classification.ai`.
|
|
177
|
+
*/
|
|
178
|
+
export declare const HUBIA_ATTACHMENT_KIND_TO_BASE_CATEGORY: {
|
|
179
|
+
readonly insurance_card: "insurance_card";
|
|
180
|
+
readonly id_document: "identification_document";
|
|
181
|
+
readonly medical_exam: "medical_exam";
|
|
182
|
+
readonly prescription: "prescription";
|
|
183
|
+
readonly referral: "referral_letter";
|
|
184
|
+
readonly payment_proof: "payment_receipt";
|
|
185
|
+
readonly screenshot: "other";
|
|
186
|
+
readonly photo_other: "other";
|
|
187
|
+
readonly document_other: "other";
|
|
188
|
+
readonly unreadable: null;
|
|
189
|
+
};
|
|
190
|
+
export type HubiaAttachmentKind = keyof typeof HUBIA_ATTACHMENT_KIND_TO_BASE_CATEGORY;
|
|
191
|
+
/** Kind conhecido → categoria (ou null); kind desconhecido → `other`; kind vazio → null. */
|
|
192
|
+
export declare function baseCategoryForHubiaKind(kind: string | null | undefined): PatientAttachmentBaseCategory | null;
|
|
193
|
+
export declare const ATTACHMENT_LIST_DEFAULT_LIMIT = 50;
|
|
194
|
+
export declare const ATTACHMENT_LIST_MAX_LIMIT = 100;
|
|
195
|
+
/** D7: filtro `message_ids` (sidebar da feat-316), `in` sobre `source.message_id`. */
|
|
196
|
+
export declare const ATTACHMENT_LIST_MAX_MESSAGE_IDS = 30;
|
|
197
|
+
export declare const ATTACHMENT_DESCRIPTION_MAX = 1000;
|
|
198
|
+
export declare const ATTACHMENT_TAGS_MAX = 30;
|
|
199
|
+
/**
|
|
200
|
+
* Query de `GET /attachments` já interpretada (o FE serializa em query string).
|
|
201
|
+
* Exatamente um de `subject` ou `message_ids`; `message_ids` não aceita `family`/`cursor`.
|
|
202
|
+
*/
|
|
203
|
+
export interface IAttachmentListQuery {
|
|
204
|
+
/** "type:id" com type ∈ `ATTACHMENT_LIST_ROOT_TYPES`. */
|
|
205
|
+
subject?: string;
|
|
206
|
+
/** Até 30 ids de mensagem; sem família nem cursor. */
|
|
207
|
+
message_ids?: string[];
|
|
208
|
+
family?: boolean;
|
|
209
|
+
/** Interno (Q5: camada 2 desligada) — não expor na tela nem no service do FE. */
|
|
210
|
+
family_depth?: 1 | 2;
|
|
211
|
+
/** Paciente da consulta, junto de `subject=med_appointment:{id}` (migração lazy). */
|
|
212
|
+
patient?: string;
|
|
213
|
+
direction?: AttachmentDirection;
|
|
214
|
+
base_category?: PatientAttachmentBaseCategory;
|
|
215
|
+
blocked?: boolean;
|
|
216
|
+
media_kind?: AttachmentMediaKind;
|
|
217
|
+
source_kind?: AttachmentSourceKind;
|
|
218
|
+
tag?: string;
|
|
219
|
+
/** Default `ATTACHMENT_LIST_DEFAULT_LIMIT`, máx. `ATTACHMENT_LIST_MAX_LIMIT`. */
|
|
220
|
+
limit?: number;
|
|
221
|
+
/** base64url de `{ o: occurred_at ISO, id }`. */
|
|
222
|
+
cursor?: string;
|
|
223
|
+
}
|
|
224
|
+
/** Nó da família que trouxe o item quando ele não tem a key da raiz (rótulo "via …"). */
|
|
225
|
+
export interface IAttachmentVia {
|
|
226
|
+
type: ExternalObjectType;
|
|
227
|
+
id: string;
|
|
228
|
+
display_name?: string | null;
|
|
229
|
+
relation?: IExternalLinkRelation | null;
|
|
230
|
+
channel_type?: string | null;
|
|
231
|
+
}
|
|
232
|
+
export type AttachmentListItemOrigin = "collection" | "legacy_array";
|
|
233
|
+
export interface IAttachmentListItem extends IAttachment {
|
|
234
|
+
via?: IAttachmentVia | null;
|
|
235
|
+
/** Quantas outras cópias com o mesmo `file.sha256` foram recolhidas neste item, na página. */
|
|
236
|
+
duplicates?: number;
|
|
237
|
+
can_edit: boolean;
|
|
238
|
+
origin: AttachmentListItemOrigin;
|
|
239
|
+
}
|
|
240
|
+
export interface IAttachmentFamilyContext {
|
|
241
|
+
/** Nós da família cujos anexos entraram (camada 1: vínculos confirmed/legacy). */
|
|
242
|
+
nodes?: IAttachmentVia[];
|
|
243
|
+
/** Teto de keys atingido (120); parte da família ficou de fora. */
|
|
244
|
+
truncated?: boolean;
|
|
245
|
+
/** Família pedida mas omitida (sem permissão de leitura do tipo oposto/chat). */
|
|
246
|
+
omitted?: "permission" | null;
|
|
247
|
+
}
|
|
248
|
+
export interface IAttachmentListResponse {
|
|
249
|
+
ok: true;
|
|
250
|
+
items: IAttachmentListItem[];
|
|
251
|
+
next_cursor: string | null;
|
|
252
|
+
family?: IAttachmentFamilyContext;
|
|
253
|
+
/** Itens migrados do array do paciente nesta chamada (migração lazy, Q7). */
|
|
254
|
+
migrated?: number;
|
|
255
|
+
}
|
|
256
|
+
/** Vínculo adicionado/removido pelo PATCH: só tipos de `ATTACHMENT_SUBJECT_TYPES`. */
|
|
257
|
+
export interface IAttachmentSubjectRef {
|
|
258
|
+
type: AttachmentSubjectType;
|
|
259
|
+
id: string;
|
|
260
|
+
label?: string;
|
|
261
|
+
}
|
|
262
|
+
/** Corpo de `PATCH /attachments/:id` (zod `zAttachmentPatchBodySchema`, strict). */
|
|
263
|
+
export interface IAttachmentPatchBody {
|
|
264
|
+
category?: string | null;
|
|
265
|
+
base_category?: PatientAttachmentBaseCategory | null;
|
|
266
|
+
category_color?: string | null;
|
|
267
|
+
description?: string | null;
|
|
268
|
+
tags?: ITag[];
|
|
269
|
+
add_links?: IAttachmentSubjectRef[];
|
|
270
|
+
remove_links?: IAttachmentSubjectRef[];
|
|
271
|
+
}
|
|
272
|
+
export interface IAttachmentPatchResponse {
|
|
273
|
+
ok: true;
|
|
274
|
+
item: IAttachmentListItem;
|
|
275
|
+
}
|
|
276
|
+
/** Resposta de `GET /attachments/:id/signed-url` (TTL 1 h; quarentena 5 min). */
|
|
277
|
+
export interface IAttachmentSignedUrlResponse {
|
|
278
|
+
ok: true;
|
|
279
|
+
url: string;
|
|
280
|
+
filename: string;
|
|
281
|
+
expires_at: string;
|
|
282
|
+
}
|
|
283
|
+
/** Corpo de `POST /attachments/reindex`: só republica o evento de indexação. */
|
|
284
|
+
export interface IAttachmentReindexBody {
|
|
285
|
+
thread_id: string;
|
|
286
|
+
message_id?: string;
|
|
287
|
+
}
|
|
288
|
+
export interface IAttachmentReindexResponse {
|
|
289
|
+
ok: true;
|
|
290
|
+
published: number;
|
|
291
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Tipos do evo-docs — feat-312 "Anexos unificados".
|
|
3
|
+
// Schemas zod correspondentes ficam em src/apps/evo-docs/zod-schemas.ts; estes tipos são
|
|
4
|
+
// escritos à mão e mantidos em paralelo (convenção do projeto: `apps/` = zod, `types/` =
|
|
5
|
+
// interfaces TS). Contrato: hub-medica-docs/features/feat-312-anexos-unificados/plan.md
|
|
6
|
+
// (§2.1 entidade, §2.3 evento de indexação, §2.4 mapa kind → base_category, §2.7 API).
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.ATTACHMENT_TAGS_MAX = exports.ATTACHMENT_DESCRIPTION_MAX = exports.ATTACHMENT_LIST_MAX_MESSAGE_IDS = exports.ATTACHMENT_LIST_MAX_LIMIT = exports.ATTACHMENT_LIST_DEFAULT_LIMIT = exports.HUBIA_ATTACHMENT_KIND_TO_BASE_CATEGORY = exports.ATTACHMENT_APPLY_MIN_CONFIDENCE = exports.AttachmentIndexReasonEnum = exports.ATTACHMENT_LIST_ROOT_TYPES = exports.ATTACHMENT_SUBJECT_TYPES = exports.AttachmentMediaKindEnum = exports.AttachmentClassificationSourceEnum = exports.AttachmentDirectionEnum = exports.ATTACHMENT_MESSAGE_SOURCE_KINDS = exports.AttachmentSourceKindEnum = void 0;
|
|
23
|
+
exports.isAttachmentSubjectType = isAttachmentSubjectType;
|
|
24
|
+
exports.attachmentSubjectKey = attachmentSubjectKey;
|
|
25
|
+
exports.baseCategoryForHubiaKind = baseCategoryForHubiaKind;
|
|
26
|
+
const shared_1 = require("../shared");
|
|
27
|
+
const dic_1 = require("../evo-med/dic");
|
|
28
|
+
__exportStar(require("./fb_collections"), exports);
|
|
29
|
+
// ───────── Enums ─────────
|
|
30
|
+
/** De onde o anexo veio. Fonte A = upload da ficha; B = chat; C = e-mail. */
|
|
31
|
+
exports.AttachmentSourceKindEnum = {
|
|
32
|
+
PatientUpload: "patient_upload",
|
|
33
|
+
AppointmentUpload: "appointment_upload",
|
|
34
|
+
ChatMessage: "chat_message",
|
|
35
|
+
EmailMessage: "email_message",
|
|
36
|
+
/** Reservado, sem escritor na v1 (D5: entra num 2º momento). */
|
|
37
|
+
HistoryImport: "history_import",
|
|
38
|
+
/** Reservado, sem escritor na v1. */
|
|
39
|
+
PlatformGenerated: "platform_generated",
|
|
40
|
+
};
|
|
41
|
+
/** Fontes que são troca de mensagem: nelas `source.direction` é obrigatório (Q9). */
|
|
42
|
+
exports.ATTACHMENT_MESSAGE_SOURCE_KINDS = [
|
|
43
|
+
exports.AttachmentSourceKindEnum.ChatMessage,
|
|
44
|
+
exports.AttachmentSourceKindEnum.EmailMessage,
|
|
45
|
+
];
|
|
46
|
+
/** Recebido × enviado pela clínica (Q9). `null` em upload da ficha. */
|
|
47
|
+
exports.AttachmentDirectionEnum = {
|
|
48
|
+
Inbound: "inbound",
|
|
49
|
+
Outbound: "outbound",
|
|
50
|
+
};
|
|
51
|
+
/** Quem decidiu a categoria vigente. Humano nunca é sobrescrito pela IA. */
|
|
52
|
+
exports.AttachmentClassificationSourceEnum = {
|
|
53
|
+
Human: "human",
|
|
54
|
+
Hubia: "hubia",
|
|
55
|
+
None: "none",
|
|
56
|
+
};
|
|
57
|
+
exports.AttachmentMediaKindEnum = {
|
|
58
|
+
Image: "image",
|
|
59
|
+
Document: "document",
|
|
60
|
+
Audio: "audio",
|
|
61
|
+
Video: "video",
|
|
62
|
+
Other: "other",
|
|
63
|
+
};
|
|
64
|
+
/** Tipos de sujeito aceitos em `externalLinks` do anexo (subconjunto de ExternalObjectTypeEnum). */
|
|
65
|
+
exports.ATTACHMENT_SUBJECT_TYPES = [
|
|
66
|
+
shared_1.ExternalObjectTypeEnum.MedPatient,
|
|
67
|
+
shared_1.ExternalObjectTypeEnum.CrmLead,
|
|
68
|
+
shared_1.ExternalObjectTypeEnum.MedAppointment,
|
|
69
|
+
shared_1.ExternalObjectTypeEnum.ChatContact,
|
|
70
|
+
];
|
|
71
|
+
/** Raízes aceitas em `GET /attachments?subject=type:id` (§2.6). `chat_contact` não é raiz. */
|
|
72
|
+
exports.ATTACHMENT_LIST_ROOT_TYPES = [
|
|
73
|
+
shared_1.ExternalObjectTypeEnum.MedPatient,
|
|
74
|
+
shared_1.ExternalObjectTypeEnum.CrmLead,
|
|
75
|
+
shared_1.ExternalObjectTypeEnum.MedAppointment,
|
|
76
|
+
];
|
|
77
|
+
function isAttachmentSubjectType(type) {
|
|
78
|
+
return (typeof type === "string" &&
|
|
79
|
+
exports.ATTACHMENT_SUBJECT_TYPES.indexOf(type) >= 0);
|
|
80
|
+
}
|
|
81
|
+
/** Chave de `externalLinkKeys`: `"type:id"`. */
|
|
82
|
+
function attachmentSubjectKey(type, id) {
|
|
83
|
+
return `${type}:${id}`;
|
|
84
|
+
}
|
|
85
|
+
// ───────── Evento de indexação (§2.3) ─────────
|
|
86
|
+
/** Motivo da publicação: mensagem persistida ou republicação manual (`POST /attachments/reindex`). */
|
|
87
|
+
exports.AttachmentIndexReasonEnum = {
|
|
88
|
+
Message: "message",
|
|
89
|
+
Reindex: "reindex",
|
|
90
|
+
};
|
|
91
|
+
// ───────── Classificação (§2.4) ─────────
|
|
92
|
+
/** Confiança mínima para a sugestão da HubIA virar categoria (D4; mesma do classificador). */
|
|
93
|
+
exports.ATTACHMENT_APPLY_MIN_CONFIDENCE = 0.7;
|
|
94
|
+
/**
|
|
95
|
+
* `kind` do classificador da HubIA → categoria base da feat-021. `unreadable` não sugere.
|
|
96
|
+
* `skipped` é do use case (não é kind do modelo) e não grava `classification.ai`.
|
|
97
|
+
*/
|
|
98
|
+
exports.HUBIA_ATTACHMENT_KIND_TO_BASE_CATEGORY = {
|
|
99
|
+
insurance_card: dic_1.PatientAttachmentBaseCategoryEnum.InsuranceCard,
|
|
100
|
+
id_document: dic_1.PatientAttachmentBaseCategoryEnum.IdentificationDocument,
|
|
101
|
+
medical_exam: dic_1.PatientAttachmentBaseCategoryEnum.MedicalExam,
|
|
102
|
+
prescription: dic_1.PatientAttachmentBaseCategoryEnum.Prescription,
|
|
103
|
+
referral: dic_1.PatientAttachmentBaseCategoryEnum.ReferralLetter,
|
|
104
|
+
payment_proof: dic_1.PatientAttachmentBaseCategoryEnum.PaymentReceipt,
|
|
105
|
+
screenshot: dic_1.PatientAttachmentBaseCategoryEnum.Other,
|
|
106
|
+
photo_other: dic_1.PatientAttachmentBaseCategoryEnum.Other,
|
|
107
|
+
document_other: dic_1.PatientAttachmentBaseCategoryEnum.Other,
|
|
108
|
+
unreadable: null,
|
|
109
|
+
};
|
|
110
|
+
/** Kind conhecido → categoria (ou null); kind desconhecido → `other`; kind vazio → null. */
|
|
111
|
+
function baseCategoryForHubiaKind(kind) {
|
|
112
|
+
if (typeof kind !== "string" || kind.trim() === "")
|
|
113
|
+
return null;
|
|
114
|
+
if (Object.prototype.hasOwnProperty.call(exports.HUBIA_ATTACHMENT_KIND_TO_BASE_CATEGORY, kind)) {
|
|
115
|
+
return exports.HUBIA_ATTACHMENT_KIND_TO_BASE_CATEGORY[kind];
|
|
116
|
+
}
|
|
117
|
+
return dic_1.PatientAttachmentBaseCategoryEnum.Other;
|
|
118
|
+
}
|
|
119
|
+
// ───────── API do hub-omni (`hubomni_admin`, §2.7) ─────────
|
|
120
|
+
exports.ATTACHMENT_LIST_DEFAULT_LIMIT = 50;
|
|
121
|
+
exports.ATTACHMENT_LIST_MAX_LIMIT = 100;
|
|
122
|
+
/** D7: filtro `message_ids` (sidebar da feat-316), `in` sobre `source.message_id`. */
|
|
123
|
+
exports.ATTACHMENT_LIST_MAX_MESSAGE_IDS = 30;
|
|
124
|
+
exports.ATTACHMENT_DESCRIPTION_MAX = 1000;
|
|
125
|
+
exports.ATTACHMENT_TAGS_MAX = 30;
|