evo360-types 1.3.762 → 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/apps/evo-task/zod-schemas.d.ts +52 -52
- package/dist/apps/evo-task/zod-schemas.js +3 -0
- package/dist/apps/evo-task/zod-schemas.ts +3 -0
- package/dist/apps/hub-automation/zod-schemas.d.ts +941 -172
- package/dist/apps/hub-automation/zod-schemas.js +68 -4
- package/dist/apps/hub-automation/zod-schemas.ts +72 -3
- 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/dist/types/evo-reports/index.d.ts +3 -1
- package/dist/types/evo-reports/index.ts +8 -1
- package/dist/types/evo-task/index.d.ts +1 -0
- package/dist/types/evo-task/index.js +7 -0
- package/dist/types/evo-task/index.ts +7 -0
- package/dist/types/hub-automation/index.d.ts +59 -2
- package/dist/types/hub-automation/index.js +16 -3
- package/dist/types/hub-automation/index.ts +116 -11
- package/package.json +1 -1
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.zAutomationTriggerRequestSchema = exports.zAutomationDryRunRequestSchema = exports.zHubAutomationConfigSchema = exports.zAutomationRoutineUpdateRequestSchema = exports.zAutomationRoutineWriteSchema = exports.zAutomationRoutineSchema = exports.zAutomationBranchModeSchema = exports.zAutomationBranchSchema = exports.zAutomationOutputSchema = exports.zAutomationActionOutputSchema = exports.zAutomationHumanTaskOutputSchema = exports.zAutomationAutoTaskOutputSchema = exports.zAutomationExecuteAtSchema = exports.zAutomationConditionGroupSchema = exports.zAutomationConditionSchema = exports.zAutomationOperatorSchema = exports.zAutomationSelectionSchema = exports.zAutomationPatientSelectionSchema = exports.zAutomationLeadSelectionSchema = exports.zAutomationAppointmentSelectionSchema = exports.zAutomationAppointmentModeSchema = exports.zAutomationTimeOfDayRangeSchema = exports.zAutomationTimeOfDaySchema = exports.zAutomationDateWindowSchema = exports.zAutomationDateOffsetModeSchema = exports.zAutomationTriggerSchema = exports.zAutomationEventTriggerSchema = exports.zAutomationWebhookTriggerSchema = exports.zAutomationCronTriggerSchema = void 0;
|
|
3
|
+
exports.zMessagePreviewRequestSchema = exports.zPatientBirthdayMessagePayloadSchema = exports.zGeneratedMessageChannelSchema = exports.zAutomationTriggerRequestSchema = exports.zAutomationDryRunRequestSchema = exports.zHubAutomationConfigSchema = exports.zAutomationRoutineUpdateRequestSchema = exports.zAutomationRoutineWriteSchema = exports.zAutomationRoutineSchema = exports.zAutomationBranchModeSchema = exports.zAutomationBranchSchema = exports.zAutomationOutputSchema = exports.zAutomationActionOutputSchema = exports.zAutomationHumanTaskOutputSchema = exports.zAutomationAutoTaskOutputSchema = exports.zAutomationExecuteAtSchema = exports.zAutomationConditionGroupSchema = exports.zAutomationConditionSchema = exports.zAutomationOperatorSchema = exports.zAutomationSelectionSchema = exports.zAutomationPatientSelectionSchema = exports.zAutomationLeadSelectionSchema = exports.zAutomationAppointmentSelectionSchema = exports.zAutomationAgeRangeSchema = exports.zAutomationPatientSexSchema = exports.zAutomationAppointmentModeSchema = exports.zAutomationTimeOfDayRangeSchema = exports.zAutomationTimeOfDaySchema = exports.zAutomationDateWindowSchema = exports.zAutomationDateOffsetModeSchema = exports.zAutomationTriggerSchema = exports.zAutomationEventTriggerSchema = exports.zAutomationWebhookTriggerSchema = exports.zAutomationCronTriggerSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const domain_events_1 = require("../../types/domain-events");
|
|
6
|
+
const hub_automation_1 = require("../../types/hub-automation");
|
|
6
7
|
const zod_schemas_1 = require("../evo-task/zod-schemas");
|
|
7
8
|
// ------------------------------------------------------
|
|
8
9
|
// Trigger (cron sweep | webhook reverse-trigger)
|
|
@@ -62,6 +63,22 @@ exports.zAutomationAppointmentModeSchema = zod_1.z.enum([
|
|
|
62
63
|
"telemedicine",
|
|
63
64
|
"in_person",
|
|
64
65
|
]);
|
|
66
|
+
// feat-311: patient filters (shared by the `appointment` and `patient` blocks).
|
|
67
|
+
// Data comes from the PATIENT doc; absence is strict (see the TS contract).
|
|
68
|
+
exports.zAutomationPatientSexSchema = zod_1.z.enum(["female", "male", "other"]);
|
|
69
|
+
// Inclusive age range in full years; at least one bound, min <= max.
|
|
70
|
+
exports.zAutomationAgeRangeSchema = zod_1.z
|
|
71
|
+
.object({
|
|
72
|
+
min: zod_1.z.number().int().min(0).max(130).optional(),
|
|
73
|
+
max: zod_1.z.number().int().min(0).max(130).optional(),
|
|
74
|
+
})
|
|
75
|
+
.refine((r) => r.min !== undefined || r.max !== undefined, {
|
|
76
|
+
message: "min or max required",
|
|
77
|
+
})
|
|
78
|
+
.refine((r) => r.min === undefined || r.max === undefined || r.min <= r.max, {
|
|
79
|
+
message: "min must be <= max",
|
|
80
|
+
path: ["max"],
|
|
81
|
+
});
|
|
65
82
|
exports.zAutomationAppointmentSelectionSchema = zod_1.z.object({
|
|
66
83
|
target: zod_1.z.literal("appointment"),
|
|
67
84
|
appointment: zod_1.z.object({
|
|
@@ -105,12 +122,18 @@ exports.zAutomationAppointmentSelectionSchema = zod_1.z.object({
|
|
|
105
122
|
message: "time_range.start and time_range.end must differ",
|
|
106
123
|
})
|
|
107
124
|
.optional(),
|
|
125
|
+
// ---- feat-311: patient filters (patient doc; strict absence).
|
|
126
|
+
patient_sex_in: zod_1.z.array(exports.zAutomationPatientSexSchema).optional(),
|
|
127
|
+
patient_sex_not_in: zod_1.z.array(exports.zAutomationPatientSexSchema).optional(),
|
|
128
|
+
patient_age: exports.zAutomationAgeRangeSchema.optional(),
|
|
108
129
|
}),
|
|
109
130
|
});
|
|
110
131
|
// feat-085 (F3): lead/patient selections (domain-event targets). The `target`
|
|
111
|
-
// discriminant selects the branch.
|
|
112
|
-
//
|
|
113
|
-
//
|
|
132
|
+
// discriminant selects the branch. Lead filters and the patient status/source/
|
|
133
|
+
// tag filters are reserved (see the TS contract): the event consumer pre-loads
|
|
134
|
+
// the single target, so they are not enforced at event runtime.
|
|
135
|
+
// feat-311: `patient.birthday` turns the patient selection into a cron/webhook
|
|
136
|
+
// birthday SWEEP, where the patient sex/age filters ARE enforced.
|
|
114
137
|
exports.zAutomationLeadSelectionSchema = zod_1.z.object({
|
|
115
138
|
target: zod_1.z.literal("lead"),
|
|
116
139
|
lead: zod_1.z.object({
|
|
@@ -126,6 +149,13 @@ exports.zAutomationPatientSelectionSchema = zod_1.z.object({
|
|
|
126
149
|
status_in: zod_1.z.array(zod_1.z.string()).optional(),
|
|
127
150
|
source_codes: zod_1.z.array(zod_1.z.string()).optional(),
|
|
128
151
|
tag_names: zod_1.z.array(zod_1.z.string()).optional(),
|
|
152
|
+
// ---- feat-311: birthday sweep (cron/webhook only) + patient filters.
|
|
153
|
+
birthday: zod_1.z
|
|
154
|
+
.object({ offset_days: zod_1.z.number().int().min(-30).max(30) })
|
|
155
|
+
.optional(),
|
|
156
|
+
patient_sex_in: zod_1.z.array(exports.zAutomationPatientSexSchema).optional(),
|
|
157
|
+
patient_sex_not_in: zod_1.z.array(exports.zAutomationPatientSexSchema).optional(),
|
|
158
|
+
patient_age: exports.zAutomationAgeRangeSchema.optional(),
|
|
129
159
|
}),
|
|
130
160
|
});
|
|
131
161
|
exports.zAutomationSelectionSchema = zod_1.z.discriminatedUnion("target", [
|
|
@@ -335,3 +365,37 @@ exports.zAutomationTriggerRequestSchema = zod_1.z.object({
|
|
|
335
365
|
.optional(),
|
|
336
366
|
force: zod_1.z.boolean().optional().default(false),
|
|
337
367
|
});
|
|
368
|
+
// ------------------------------------------------------
|
|
369
|
+
// feat-311 (F3): "Mensagem de aniversário (IA)" output
|
|
370
|
+
// ------------------------------------------------------
|
|
371
|
+
exports.zGeneratedMessageChannelSchema = zod_1.z.enum(["whatsapp", "email"]);
|
|
372
|
+
// Payload of the `patient_birthday_message` auto task. `.passthrough()` because
|
|
373
|
+
// the materializer injects extra keys (e.g. `externalLinks`). `prompt` is
|
|
374
|
+
// OPTIONAL here on purpose: the handler itself reports `prompt_missing` (P3).
|
|
375
|
+
exports.zPatientBirthdayMessagePayloadSchema = zod_1.z
|
|
376
|
+
.object({
|
|
377
|
+
patient_id: zod_1.z.string().min(1),
|
|
378
|
+
channels: zod_1.z.array(exports.zGeneratedMessageChannelSchema).optional(),
|
|
379
|
+
whatsapp_channel_id: zod_1.z.string().optional(),
|
|
380
|
+
whatsapp_template_id: zod_1.z.string().optional(),
|
|
381
|
+
email_channel_id: zod_1.z.string().optional(),
|
|
382
|
+
email_template_id: zod_1.z.string().optional(),
|
|
383
|
+
department_id: zod_1.z.string().optional(),
|
|
384
|
+
prompt: zod_1.z.string().max(hub_automation_1.MESSAGE_PROMPT_MAX_CHARS).optional(),
|
|
385
|
+
birthday_date: zod_1.z
|
|
386
|
+
.string()
|
|
387
|
+
.regex(/^\d{4}-\d{2}-\d{2}$/, "expected yyyy-MM-dd")
|
|
388
|
+
.optional(),
|
|
389
|
+
force_send: zod_1.z.boolean().optional(),
|
|
390
|
+
})
|
|
391
|
+
.passthrough();
|
|
392
|
+
// "Testar prompt" (POST /outputs/preview-message on hub_automation_admin).
|
|
393
|
+
exports.zMessagePreviewRequestSchema = zod_1.z.object({
|
|
394
|
+
patient_id: zod_1.z.string().min(1),
|
|
395
|
+
prompt: zod_1.z.string().trim().min(1).max(hub_automation_1.MESSAGE_PROMPT_MAX_CHARS),
|
|
396
|
+
channel: exports.zGeneratedMessageChannelSchema,
|
|
397
|
+
birthday_date: zod_1.z
|
|
398
|
+
.string()
|
|
399
|
+
.regex(/^\d{4}-\d{2}-\d{2}$/, "expected yyyy-MM-dd")
|
|
400
|
+
.optional(),
|
|
401
|
+
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { DOMAIN_EVENT_ORIGINS } from "../../types/domain-events";
|
|
3
|
+
import { MESSAGE_PROMPT_MAX_CHARS } from "../../types/hub-automation";
|
|
3
4
|
import {
|
|
4
5
|
zTaskAutoHandlerSchema,
|
|
5
6
|
zTaskRetryPolicySchema,
|
|
@@ -73,6 +74,24 @@ export const zAutomationAppointmentModeSchema = z.enum([
|
|
|
73
74
|
"in_person",
|
|
74
75
|
]);
|
|
75
76
|
|
|
77
|
+
// feat-311: patient filters (shared by the `appointment` and `patient` blocks).
|
|
78
|
+
// Data comes from the PATIENT doc; absence is strict (see the TS contract).
|
|
79
|
+
export const zAutomationPatientSexSchema = z.enum(["female", "male", "other"]);
|
|
80
|
+
|
|
81
|
+
// Inclusive age range in full years; at least one bound, min <= max.
|
|
82
|
+
export const zAutomationAgeRangeSchema = z
|
|
83
|
+
.object({
|
|
84
|
+
min: z.number().int().min(0).max(130).optional(),
|
|
85
|
+
max: z.number().int().min(0).max(130).optional(),
|
|
86
|
+
})
|
|
87
|
+
.refine((r) => r.min !== undefined || r.max !== undefined, {
|
|
88
|
+
message: "min or max required",
|
|
89
|
+
})
|
|
90
|
+
.refine((r) => r.min === undefined || r.max === undefined || r.min <= r.max, {
|
|
91
|
+
message: "min must be <= max",
|
|
92
|
+
path: ["max"],
|
|
93
|
+
});
|
|
94
|
+
|
|
76
95
|
export const zAutomationAppointmentSelectionSchema = z.object({
|
|
77
96
|
target: z.literal("appointment"),
|
|
78
97
|
appointment: z.object({
|
|
@@ -117,13 +136,19 @@ export const zAutomationAppointmentSelectionSchema = z.object({
|
|
|
117
136
|
message: "time_range.start and time_range.end must differ",
|
|
118
137
|
})
|
|
119
138
|
.optional(),
|
|
139
|
+
// ---- feat-311: patient filters (patient doc; strict absence).
|
|
140
|
+
patient_sex_in: z.array(zAutomationPatientSexSchema).optional(),
|
|
141
|
+
patient_sex_not_in: z.array(zAutomationPatientSexSchema).optional(),
|
|
142
|
+
patient_age: zAutomationAgeRangeSchema.optional(),
|
|
120
143
|
}),
|
|
121
144
|
});
|
|
122
145
|
|
|
123
146
|
// feat-085 (F3): lead/patient selections (domain-event targets). The `target`
|
|
124
|
-
// discriminant selects the branch.
|
|
125
|
-
//
|
|
126
|
-
//
|
|
147
|
+
// discriminant selects the branch. Lead filters and the patient status/source/
|
|
148
|
+
// tag filters are reserved (see the TS contract): the event consumer pre-loads
|
|
149
|
+
// the single target, so they are not enforced at event runtime.
|
|
150
|
+
// feat-311: `patient.birthday` turns the patient selection into a cron/webhook
|
|
151
|
+
// birthday SWEEP, where the patient sex/age filters ARE enforced.
|
|
127
152
|
export const zAutomationLeadSelectionSchema = z.object({
|
|
128
153
|
target: z.literal("lead"),
|
|
129
154
|
lead: z.object({
|
|
@@ -140,6 +165,13 @@ export const zAutomationPatientSelectionSchema = z.object({
|
|
|
140
165
|
status_in: z.array(z.string()).optional(),
|
|
141
166
|
source_codes: z.array(z.string()).optional(),
|
|
142
167
|
tag_names: z.array(z.string()).optional(),
|
|
168
|
+
// ---- feat-311: birthday sweep (cron/webhook only) + patient filters.
|
|
169
|
+
birthday: z
|
|
170
|
+
.object({ offset_days: z.number().int().min(-30).max(30) })
|
|
171
|
+
.optional(),
|
|
172
|
+
patient_sex_in: z.array(zAutomationPatientSexSchema).optional(),
|
|
173
|
+
patient_sex_not_in: z.array(zAutomationPatientSexSchema).optional(),
|
|
174
|
+
patient_age: zAutomationAgeRangeSchema.optional(),
|
|
143
175
|
}),
|
|
144
176
|
});
|
|
145
177
|
|
|
@@ -378,3 +410,40 @@ export const zAutomationTriggerRequestSchema = z.object({
|
|
|
378
410
|
.optional(),
|
|
379
411
|
force: z.boolean().optional().default(false),
|
|
380
412
|
});
|
|
413
|
+
|
|
414
|
+
// ------------------------------------------------------
|
|
415
|
+
// feat-311 (F3): "Mensagem de aniversário (IA)" output
|
|
416
|
+
// ------------------------------------------------------
|
|
417
|
+
export const zGeneratedMessageChannelSchema = z.enum(["whatsapp", "email"]);
|
|
418
|
+
|
|
419
|
+
// Payload of the `patient_birthday_message` auto task. `.passthrough()` because
|
|
420
|
+
// the materializer injects extra keys (e.g. `externalLinks`). `prompt` is
|
|
421
|
+
// OPTIONAL here on purpose: the handler itself reports `prompt_missing` (P3).
|
|
422
|
+
export const zPatientBirthdayMessagePayloadSchema = z
|
|
423
|
+
.object({
|
|
424
|
+
patient_id: z.string().min(1),
|
|
425
|
+
channels: z.array(zGeneratedMessageChannelSchema).optional(),
|
|
426
|
+
whatsapp_channel_id: z.string().optional(),
|
|
427
|
+
whatsapp_template_id: z.string().optional(),
|
|
428
|
+
email_channel_id: z.string().optional(),
|
|
429
|
+
email_template_id: z.string().optional(),
|
|
430
|
+
department_id: z.string().optional(),
|
|
431
|
+
prompt: z.string().max(MESSAGE_PROMPT_MAX_CHARS).optional(),
|
|
432
|
+
birthday_date: z
|
|
433
|
+
.string()
|
|
434
|
+
.regex(/^\d{4}-\d{2}-\d{2}$/, "expected yyyy-MM-dd")
|
|
435
|
+
.optional(),
|
|
436
|
+
force_send: z.boolean().optional(),
|
|
437
|
+
})
|
|
438
|
+
.passthrough();
|
|
439
|
+
|
|
440
|
+
// "Testar prompt" (POST /outputs/preview-message on hub_automation_admin).
|
|
441
|
+
export const zMessagePreviewRequestSchema = z.object({
|
|
442
|
+
patient_id: z.string().min(1),
|
|
443
|
+
prompt: z.string().trim().min(1).max(MESSAGE_PROMPT_MAX_CHARS),
|
|
444
|
+
channel: zGeneratedMessageChannelSchema,
|
|
445
|
+
birthday_date: z
|
|
446
|
+
.string()
|
|
447
|
+
.regex(/^\d{4}-\d{2}-\d{2}$/, "expected yyyy-MM-dd")
|
|
448
|
+
.optional(),
|
|
449
|
+
});
|
package/dist/index.d.ts
CHANGED
|
@@ -37,6 +37,7 @@ export * from "./types/evo-mcp";
|
|
|
37
37
|
export * from "./types/evo-reports";
|
|
38
38
|
export * from "./types/evo-telemedicine";
|
|
39
39
|
export * from "./types/evo-modules";
|
|
40
|
+
export * from "./types/evo-docs";
|
|
40
41
|
export * from "./apps/shared/zod-schemas";
|
|
41
42
|
export * from "./apps/evo-core/zod-schemas";
|
|
42
43
|
export * from "./apps/evo-core/nexus-claims";
|
|
@@ -84,3 +85,4 @@ export * from "./apps/hub-automation/zod-schemas";
|
|
|
84
85
|
export * from "./apps/evo-integrations/zod-schemas";
|
|
85
86
|
export * from "./apps/evo-telemedicine/zod-schemas";
|
|
86
87
|
export * from "./apps/evo-modules/zod-schemas";
|
|
88
|
+
export * from "./apps/evo-docs/zod-schemas";
|
package/dist/index.js
CHANGED
|
@@ -54,6 +54,7 @@ __exportStar(require("./types/evo-mcp"), exports);
|
|
|
54
54
|
__exportStar(require("./types/evo-reports"), exports);
|
|
55
55
|
__exportStar(require("./types/evo-telemedicine"), exports);
|
|
56
56
|
__exportStar(require("./types/evo-modules"), exports);
|
|
57
|
+
__exportStar(require("./types/evo-docs"), exports);
|
|
57
58
|
// zod schemas
|
|
58
59
|
__exportStar(require("./apps/shared/zod-schemas"), exports);
|
|
59
60
|
__exportStar(require("./apps/evo-core/zod-schemas"), exports);
|
|
@@ -102,3 +103,4 @@ __exportStar(require("./apps/hub-automation/zod-schemas"), exports);
|
|
|
102
103
|
__exportStar(require("./apps/evo-integrations/zod-schemas"), exports);
|
|
103
104
|
__exportStar(require("./apps/evo-telemedicine/zod-schemas"), exports);
|
|
104
105
|
__exportStar(require("./apps/evo-modules/zod-schemas"), exports);
|
|
106
|
+
__exportStar(require("./apps/evo-docs/zod-schemas"), exports);
|
package/dist/index.ts
CHANGED
|
@@ -38,6 +38,7 @@ export * from "./types/evo-mcp";
|
|
|
38
38
|
export * from "./types/evo-reports";
|
|
39
39
|
export * from "./types/evo-telemedicine";
|
|
40
40
|
export * from "./types/evo-modules";
|
|
41
|
+
export * from "./types/evo-docs";
|
|
41
42
|
|
|
42
43
|
// zod schemas
|
|
43
44
|
export * from "./apps/shared/zod-schemas";
|
|
@@ -87,3 +88,4 @@ export * from "./apps/hub-automation/zod-schemas";
|
|
|
87
88
|
export * from "./apps/evo-integrations/zod-schemas";
|
|
88
89
|
export * from "./apps/evo-telemedicine/zod-schemas";
|
|
89
90
|
export * from "./apps/evo-modules/zod-schemas";
|
|
91
|
+
export * from "./apps/evo-docs/zod-schemas";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ATTACHMENTS_COLLECTION = exports.EVO_DOCS_APP = void 0;
|
|
4
|
+
// EVO Docs Application Doc (feat-312) — app neutra entre evo-med e evo-chat que guarda
|
|
5
|
+
// os documentos do tenant (anexos hoje; documentos gerados e EMR no futuro).
|
|
6
|
+
exports.EVO_DOCS_APP = "evo-docs";
|
|
7
|
+
// Anexo unificado: tenants/{t}/apps/evo-docs/attachments/{id}
|
|
8
|
+
// Também é o nome da coleção no índice de tags do evo-tags (`tag-collection-index/attachments`).
|
|
9
|
+
exports.ATTACHMENTS_COLLECTION = "attachments";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// EVO Docs Application Doc (feat-312) — app neutra entre evo-med e evo-chat que guarda
|
|
2
|
+
// os documentos do tenant (anexos hoje; documentos gerados e EMR no futuro).
|
|
3
|
+
export const EVO_DOCS_APP = "evo-docs";
|
|
4
|
+
|
|
5
|
+
// Anexo unificado: tenants/{t}/apps/evo-docs/attachments/{id}
|
|
6
|
+
// Também é o nome da coleção no índice de tags do evo-tags (`tag-collection-index/attachments`).
|
|
7
|
+
export const ATTACHMENTS_COLLECTION = "attachments";
|
|
@@ -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
|
+
}
|