evo360-types 1.3.417 → 1.3.423
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-campaigns/zod-schemas.d.ts +1680 -0
- package/dist/apps/evo-campaigns/zod-schemas.js +5 -0
- package/dist/apps/evo-campaigns/zod-schemas.ts +5 -0
- package/dist/apps/hub-automation/zod-schemas.d.ts +614 -8
- package/dist/apps/hub-automation/zod-schemas.js +39 -2
- package/dist/apps/hub-automation/zod-schemas.ts +41 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.ts +1 -0
- package/dist/types/domain-events/index.d.ts +45 -0
- package/dist/types/domain-events/index.js +18 -0
- package/dist/types/domain-events/index.ts +67 -0
- package/dist/types/evo-campaigns/index.d.ts +16 -2
- package/dist/types/evo-campaigns/index.ts +16 -2
- package/dist/types/hub-automation/index.d.ts +34 -4
- package/dist/types/hub-automation/index.js +24 -1
- package/dist/types/hub-automation/index.ts +86 -4
- package/dist/types/shared/external-links.d.ts +2 -0
- package/dist/types/shared/external-links.js +2 -0
- package/dist/types/shared/external-links.ts +2 -0
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
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.zAutomationAppointmentSelectionSchema = exports.zAutomationDateWindowSchema = exports.zAutomationDateOffsetModeSchema = exports.zAutomationTriggerSchema = exports.zAutomationWebhookTriggerSchema = exports.zAutomationCronTriggerSchema = void 0;
|
|
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.zAutomationDateWindowSchema = exports.zAutomationDateOffsetModeSchema = exports.zAutomationTriggerSchema = exports.zAutomationEventTriggerSchema = exports.zAutomationWebhookTriggerSchema = exports.zAutomationCronTriggerSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const zod_schemas_1 = require("../evo-task/zod-schemas");
|
|
6
6
|
// ------------------------------------------------------
|
|
@@ -17,9 +17,21 @@ exports.zAutomationCronTriggerSchema = zod_1.z.object({
|
|
|
17
17
|
exports.zAutomationWebhookTriggerSchema = zod_1.z.object({
|
|
18
18
|
type: zod_1.z.literal("webhook"),
|
|
19
19
|
});
|
|
20
|
+
// feat-085 (F1): domain-event trigger. `actor_kinds` default is applied by the
|
|
21
|
+
// consumer (Camada 1), not here — omitted means ['user'].
|
|
22
|
+
exports.zAutomationEventTriggerSchema = zod_1.z.object({
|
|
23
|
+
type: zod_1.z.literal("event"),
|
|
24
|
+
event: zod_1.z.object({
|
|
25
|
+
types: zod_1.z.array(zod_1.z.string().min(1)).min(1),
|
|
26
|
+
actor_kinds: zod_1.z
|
|
27
|
+
.array(zod_1.z.enum(["user", "system", "automation"]))
|
|
28
|
+
.optional(),
|
|
29
|
+
}),
|
|
30
|
+
});
|
|
20
31
|
exports.zAutomationTriggerSchema = zod_1.z.discriminatedUnion("type", [
|
|
21
32
|
exports.zAutomationCronTriggerSchema,
|
|
22
33
|
exports.zAutomationWebhookTriggerSchema,
|
|
34
|
+
exports.zAutomationEventTriggerSchema,
|
|
23
35
|
]);
|
|
24
36
|
// ------------------------------------------------------
|
|
25
37
|
// Selection (F1: appointment target only)
|
|
@@ -46,7 +58,32 @@ exports.zAutomationAppointmentSelectionSchema = zod_1.z.object({
|
|
|
46
58
|
payment_status_in: zod_1.z.array(zod_1.z.string()).optional(),
|
|
47
59
|
}),
|
|
48
60
|
});
|
|
49
|
-
|
|
61
|
+
// feat-085 (F3): lead/patient selections (domain-event targets). The `target`
|
|
62
|
+
// discriminant selects the branch. Filters are reserved (see the TS contract);
|
|
63
|
+
// the event consumer pre-loads the single target, so they are not enforced at
|
|
64
|
+
// runtime today but are validated to allow authoring lead/patient routines.
|
|
65
|
+
exports.zAutomationLeadSelectionSchema = zod_1.z.object({
|
|
66
|
+
target: zod_1.z.literal("lead"),
|
|
67
|
+
lead: zod_1.z.object({
|
|
68
|
+
status_in: zod_1.z.array(zod_1.z.string()).optional(),
|
|
69
|
+
qualification_codes: zod_1.z.array(zod_1.z.string()).optional(),
|
|
70
|
+
dist_channel_codes: zod_1.z.array(zod_1.z.string()).optional(),
|
|
71
|
+
tag_names: zod_1.z.array(zod_1.z.string()).optional(),
|
|
72
|
+
}),
|
|
73
|
+
});
|
|
74
|
+
exports.zAutomationPatientSelectionSchema = zod_1.z.object({
|
|
75
|
+
target: zod_1.z.literal("patient"),
|
|
76
|
+
patient: zod_1.z.object({
|
|
77
|
+
status_in: zod_1.z.array(zod_1.z.string()).optional(),
|
|
78
|
+
source_codes: zod_1.z.array(zod_1.z.string()).optional(),
|
|
79
|
+
tag_names: zod_1.z.array(zod_1.z.string()).optional(),
|
|
80
|
+
}),
|
|
81
|
+
});
|
|
82
|
+
exports.zAutomationSelectionSchema = zod_1.z.discriminatedUnion("target", [
|
|
83
|
+
exports.zAutomationAppointmentSelectionSchema,
|
|
84
|
+
exports.zAutomationLeadSelectionSchema,
|
|
85
|
+
exports.zAutomationPatientSelectionSchema,
|
|
86
|
+
]);
|
|
50
87
|
// ------------------------------------------------------
|
|
51
88
|
// Conditions (recursive AND/OR groups via z.lazy)
|
|
52
89
|
// ------------------------------------------------------
|
|
@@ -21,9 +21,22 @@ export const zAutomationWebhookTriggerSchema = z.object({
|
|
|
21
21
|
type: z.literal("webhook"),
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
+
// feat-085 (F1): domain-event trigger. `actor_kinds` default is applied by the
|
|
25
|
+
// consumer (Camada 1), not here — omitted means ['user'].
|
|
26
|
+
export const zAutomationEventTriggerSchema = z.object({
|
|
27
|
+
type: z.literal("event"),
|
|
28
|
+
event: z.object({
|
|
29
|
+
types: z.array(z.string().min(1)).min(1),
|
|
30
|
+
actor_kinds: z
|
|
31
|
+
.array(z.enum(["user", "system", "automation"]))
|
|
32
|
+
.optional(),
|
|
33
|
+
}),
|
|
34
|
+
});
|
|
35
|
+
|
|
24
36
|
export const zAutomationTriggerSchema = z.discriminatedUnion("type", [
|
|
25
37
|
zAutomationCronTriggerSchema,
|
|
26
38
|
zAutomationWebhookTriggerSchema,
|
|
39
|
+
zAutomationEventTriggerSchema,
|
|
27
40
|
]);
|
|
28
41
|
|
|
29
42
|
// ------------------------------------------------------
|
|
@@ -54,7 +67,34 @@ export const zAutomationAppointmentSelectionSchema = z.object({
|
|
|
54
67
|
}),
|
|
55
68
|
});
|
|
56
69
|
|
|
57
|
-
|
|
70
|
+
// feat-085 (F3): lead/patient selections (domain-event targets). The `target`
|
|
71
|
+
// discriminant selects the branch. Filters are reserved (see the TS contract);
|
|
72
|
+
// the event consumer pre-loads the single target, so they are not enforced at
|
|
73
|
+
// runtime today but are validated to allow authoring lead/patient routines.
|
|
74
|
+
export const zAutomationLeadSelectionSchema = z.object({
|
|
75
|
+
target: z.literal("lead"),
|
|
76
|
+
lead: z.object({
|
|
77
|
+
status_in: z.array(z.string()).optional(),
|
|
78
|
+
qualification_codes: z.array(z.string()).optional(),
|
|
79
|
+
dist_channel_codes: z.array(z.string()).optional(),
|
|
80
|
+
tag_names: z.array(z.string()).optional(),
|
|
81
|
+
}),
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
export const zAutomationPatientSelectionSchema = z.object({
|
|
85
|
+
target: z.literal("patient"),
|
|
86
|
+
patient: z.object({
|
|
87
|
+
status_in: z.array(z.string()).optional(),
|
|
88
|
+
source_codes: z.array(z.string()).optional(),
|
|
89
|
+
tag_names: z.array(z.string()).optional(),
|
|
90
|
+
}),
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
export const zAutomationSelectionSchema = z.discriminatedUnion("target", [
|
|
94
|
+
zAutomationAppointmentSelectionSchema,
|
|
95
|
+
zAutomationLeadSelectionSchema,
|
|
96
|
+
zAutomationPatientSelectionSchema,
|
|
97
|
+
]);
|
|
58
98
|
|
|
59
99
|
// ------------------------------------------------------
|
|
60
100
|
// Conditions (recursive AND/OR groups via z.lazy)
|
package/dist/index.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ export * from "./types/evo-notifications";
|
|
|
25
25
|
export * from "./types/evo-campaigns";
|
|
26
26
|
export * from "./types/evo-task-runner";
|
|
27
27
|
export * from "./types/hub-automation";
|
|
28
|
+
export * from "./types/domain-events";
|
|
28
29
|
export * from "./types/evo-integrations";
|
|
29
30
|
export * from "./types/nex-customers";
|
|
30
31
|
export * from "./types/nex-tenants";
|
package/dist/index.js
CHANGED
|
@@ -42,6 +42,7 @@ __exportStar(require("./types/evo-notifications"), exports);
|
|
|
42
42
|
__exportStar(require("./types/evo-campaigns"), exports);
|
|
43
43
|
__exportStar(require("./types/evo-task-runner"), exports);
|
|
44
44
|
__exportStar(require("./types/hub-automation"), exports);
|
|
45
|
+
__exportStar(require("./types/domain-events"), exports);
|
|
45
46
|
__exportStar(require("./types/evo-integrations"), exports);
|
|
46
47
|
__exportStar(require("./types/nex-customers"), exports);
|
|
47
48
|
__exportStar(require("./types/nex-tenants"), exports);
|
package/dist/index.ts
CHANGED
|
@@ -26,6 +26,7 @@ export * from "./types/evo-notifications";
|
|
|
26
26
|
export * from "./types/evo-campaigns";
|
|
27
27
|
export * from "./types/evo-task-runner";
|
|
28
28
|
export * from "./types/hub-automation";
|
|
29
|
+
export * from "./types/domain-events";
|
|
29
30
|
export * from "./types/evo-integrations";
|
|
30
31
|
export * from "./types/nex-customers";
|
|
31
32
|
export * from "./types/nex-tenants";
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** Topico central: todo emitDomainEvent() publica aqui (envelope canonico). */
|
|
2
|
+
export declare const DOMAIN_EVENTS_TOPIC: "evo-domain-events";
|
|
3
|
+
/** Versao do contrato do envelope, carimbada em `api_version`. */
|
|
4
|
+
export declare const DOMAIN_EVENT_API_VERSION: "2026-07-20";
|
|
5
|
+
/**
|
|
6
|
+
* `user` — escrita organica de um humano (userRef = users/<uid>).
|
|
7
|
+
* `system` — sync/integracao (userRef ausente ou users/system).
|
|
8
|
+
* `automation` — escrita feita pela plataforma (users/hub-automation,
|
|
9
|
+
* users/hubia-v1). E o sinal que corta o self-loop no consumidor
|
|
10
|
+
* (Camada 1: allowlist actor_kinds, default ['user']).
|
|
11
|
+
*/
|
|
12
|
+
export type DomainEventActorKind = "user" | "system" | "automation";
|
|
13
|
+
export interface IDomainEventActor {
|
|
14
|
+
kind: DomainEventActorKind;
|
|
15
|
+
/** uid do usuario, nome da automacao (hub-automation/hubia-v1) ou null/system. */
|
|
16
|
+
id: string | null;
|
|
17
|
+
}
|
|
18
|
+
export interface IDomainEventResource {
|
|
19
|
+
/** tenant (clinica) dono do recurso — chave de scoping do consumidor. */
|
|
20
|
+
tenant: string;
|
|
21
|
+
/** ex.: 'appointment', 'lead', 'patient'. */
|
|
22
|
+
kind: "appointment" | "lead" | "patient" | string;
|
|
23
|
+
id: string;
|
|
24
|
+
/** caminho Firestore do recurso, quando aplicavel. */
|
|
25
|
+
path?: string | null;
|
|
26
|
+
/** hierarquia (ex.: calendar_id do appointment) para reconstruir o alvo. */
|
|
27
|
+
parent?: {
|
|
28
|
+
calendar_id?: string;
|
|
29
|
+
} | null;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Envelope canonico de um evento de dominio. Publicado em DOMAIN_EVENTS_TOPIC.
|
|
33
|
+
* `id` (evt_<uuid>) e a chave de idempotencia/dedup usada pelo consumidor.
|
|
34
|
+
* `data` carrega a transicao SEMANTICA (before/after/changed_fields), nao um
|
|
35
|
+
* diff cru de CRUD.
|
|
36
|
+
*/
|
|
37
|
+
export interface IDomainEvent {
|
|
38
|
+
id: string;
|
|
39
|
+
type: string;
|
|
40
|
+
api_version: string;
|
|
41
|
+
occurred_at: string;
|
|
42
|
+
actor: IDomainEventActor;
|
|
43
|
+
resource: IDomainEventResource;
|
|
44
|
+
data: Record<string, unknown>;
|
|
45
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Domain events (feat-085 evo-events) — canonical BUSINESS event envelope.
|
|
3
|
+
//
|
|
4
|
+
// Substrato transversal: eventos de negocio emitidos nos models (choke points de
|
|
5
|
+
// escrita) e consumidos por N subscribers — o primeiro sendo o hub-automation
|
|
6
|
+
// (trigger.type:'event'); o segundo (futuro) webhooks publicos. Molde do envelope
|
|
7
|
+
// = nexus-webhooks (feat-059), estendido com `actor.kind:'automation'` (derivado
|
|
8
|
+
// do userRef da automacao) e `resource.tenant`/`resource.parent` (multi-tenant +
|
|
9
|
+
// hierarquia calendar/appointment).
|
|
10
|
+
//
|
|
11
|
+
// Regra do repo: `types/` = interfaces TS escritas a mao (sem zod, sem z.infer).
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.DOMAIN_EVENT_API_VERSION = exports.DOMAIN_EVENTS_TOPIC = void 0;
|
|
14
|
+
// ── Constants ──
|
|
15
|
+
/** Topico central: todo emitDomainEvent() publica aqui (envelope canonico). */
|
|
16
|
+
exports.DOMAIN_EVENTS_TOPIC = "evo-domain-events";
|
|
17
|
+
/** Versao do contrato do envelope, carimbada em `api_version`. */
|
|
18
|
+
exports.DOMAIN_EVENT_API_VERSION = "2026-07-20";
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// Domain events (feat-085 evo-events) — canonical BUSINESS event envelope.
|
|
2
|
+
//
|
|
3
|
+
// Substrato transversal: eventos de negocio emitidos nos models (choke points de
|
|
4
|
+
// escrita) e consumidos por N subscribers — o primeiro sendo o hub-automation
|
|
5
|
+
// (trigger.type:'event'); o segundo (futuro) webhooks publicos. Molde do envelope
|
|
6
|
+
// = nexus-webhooks (feat-059), estendido com `actor.kind:'automation'` (derivado
|
|
7
|
+
// do userRef da automacao) e `resource.tenant`/`resource.parent` (multi-tenant +
|
|
8
|
+
// hierarquia calendar/appointment).
|
|
9
|
+
//
|
|
10
|
+
// Regra do repo: `types/` = interfaces TS escritas a mao (sem zod, sem z.infer).
|
|
11
|
+
|
|
12
|
+
// ── Constants ──
|
|
13
|
+
|
|
14
|
+
/** Topico central: todo emitDomainEvent() publica aqui (envelope canonico). */
|
|
15
|
+
export const DOMAIN_EVENTS_TOPIC = "evo-domain-events" as const;
|
|
16
|
+
|
|
17
|
+
/** Versao do contrato do envelope, carimbada em `api_version`. */
|
|
18
|
+
export const DOMAIN_EVENT_API_VERSION = "2026-07-20" as const;
|
|
19
|
+
|
|
20
|
+
// ── Actor ──
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* `user` — escrita organica de um humano (userRef = users/<uid>).
|
|
24
|
+
* `system` — sync/integracao (userRef ausente ou users/system).
|
|
25
|
+
* `automation` — escrita feita pela plataforma (users/hub-automation,
|
|
26
|
+
* users/hubia-v1). E o sinal que corta o self-loop no consumidor
|
|
27
|
+
* (Camada 1: allowlist actor_kinds, default ['user']).
|
|
28
|
+
*/
|
|
29
|
+
export type DomainEventActorKind = "user" | "system" | "automation";
|
|
30
|
+
|
|
31
|
+
export interface IDomainEventActor {
|
|
32
|
+
kind: DomainEventActorKind;
|
|
33
|
+
/** uid do usuario, nome da automacao (hub-automation/hubia-v1) ou null/system. */
|
|
34
|
+
id: string | null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// ── Resource ──
|
|
38
|
+
|
|
39
|
+
export interface IDomainEventResource {
|
|
40
|
+
/** tenant (clinica) dono do recurso — chave de scoping do consumidor. */
|
|
41
|
+
tenant: string;
|
|
42
|
+
/** ex.: 'appointment', 'lead', 'patient'. */
|
|
43
|
+
kind: "appointment" | "lead" | "patient" | string;
|
|
44
|
+
id: string;
|
|
45
|
+
/** caminho Firestore do recurso, quando aplicavel. */
|
|
46
|
+
path?: string | null;
|
|
47
|
+
/** hierarquia (ex.: calendar_id do appointment) para reconstruir o alvo. */
|
|
48
|
+
parent?: { calendar_id?: string } | null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// ── Envelope ──
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Envelope canonico de um evento de dominio. Publicado em DOMAIN_EVENTS_TOPIC.
|
|
55
|
+
* `id` (evt_<uuid>) e a chave de idempotencia/dedup usada pelo consumidor.
|
|
56
|
+
* `data` carrega a transicao SEMANTICA (before/after/changed_fields), nao um
|
|
57
|
+
* diff cru de CRUD.
|
|
58
|
+
*/
|
|
59
|
+
export interface IDomainEvent {
|
|
60
|
+
id: string; // evt_<uuid>
|
|
61
|
+
type: string; // 'agendamento.reagendado', 'agendamento.status_alterado', ...
|
|
62
|
+
api_version: string;
|
|
63
|
+
occurred_at: string; // ISO 8601
|
|
64
|
+
actor: IDomainEventActor;
|
|
65
|
+
resource: IDomainEventResource;
|
|
66
|
+
data: Record<string, unknown>;
|
|
67
|
+
}
|
|
@@ -45,8 +45,15 @@ export interface ICampaignCta {
|
|
|
45
45
|
label: string;
|
|
46
46
|
/** WhatsApp template button position (0,1,2...). */
|
|
47
47
|
button_index?: number;
|
|
48
|
-
/** Final destination for the /qr redirect.
|
|
48
|
+
/** Final destination for the /qr redirect. Optional on WhatsApp QUICK_REPLY
|
|
49
|
+
* buttons (the tap itself is tracked); required for email CTAs and URL buttons. */
|
|
49
50
|
target_url?: string;
|
|
51
|
+
/** Email CTA destination kind (feat-081 F2.5): external URL or a wa.me deep link. */
|
|
52
|
+
dest_type?: "external_url" | "whatsapp" | null;
|
|
53
|
+
/** WA channel whose number builds the wa.me link (dest_type='whatsapp'). */
|
|
54
|
+
wa_channel_id?: string | null;
|
|
55
|
+
/** Prefilled message for the wa.me link (dest_type='whatsapp'). */
|
|
56
|
+
wa_message?: string | null;
|
|
50
57
|
}
|
|
51
58
|
export interface ICampaignPacingWindow {
|
|
52
59
|
/** 'HH:mm' local (tenant timezone). */
|
|
@@ -71,8 +78,12 @@ export interface ICampaignTicketPolicy {
|
|
|
71
78
|
export interface ICampaignMedia {
|
|
72
79
|
/** 'image' | 'video' | 'document' — WhatsApp header media type. */
|
|
73
80
|
type: string;
|
|
81
|
+
/** Full gs:// URI in WABA_MEDIA_BUCKET under tenants/<tenant>/ (feat-082/084 flow). */
|
|
74
82
|
gcs_path?: string;
|
|
75
83
|
url?: string;
|
|
84
|
+
/** Mime type of the uploaded media (drives the header component). */
|
|
85
|
+
mime_type?: string | null;
|
|
86
|
+
filename?: string | null;
|
|
76
87
|
}
|
|
77
88
|
/** Per-channel configuration (whatsapp/email) of a campaign. */
|
|
78
89
|
export interface ICampaignChannelConfig {
|
|
@@ -251,7 +262,10 @@ export interface ICampaignBucket extends IFireDoc {
|
|
|
251
262
|
counts?: ICampaignBucketCounts;
|
|
252
263
|
}
|
|
253
264
|
/** Flat field driving the batch queue (indexed). */
|
|
254
|
-
export type RecipientDispatchState = "pending" | "dispatched" | "done" | "excluded"
|
|
265
|
+
export type RecipientDispatchState = "pending" | "dispatched" | "done" | "excluded"
|
|
266
|
+
/** Campaign canceled with this recipient still pending (feat-081 F3 — formalizes
|
|
267
|
+
* what F2 stored as 'excluded'; readers must accept both on old docs). */
|
|
268
|
+
| "canceled";
|
|
255
269
|
/** Per-channel delivery status of a recipient (monotonic). */
|
|
256
270
|
export type RecipientChannelStatus = "pending" | "scheduled" | "sent" | "delivered" | "read" | "failed" | "clicked" | "replied";
|
|
257
271
|
/** Aggregated, monotonic recipient status (Portuguese labels — FE display). */
|
|
@@ -95,8 +95,15 @@ export interface ICampaignCta {
|
|
|
95
95
|
label: string;
|
|
96
96
|
/** WhatsApp template button position (0,1,2...). */
|
|
97
97
|
button_index?: number;
|
|
98
|
-
/** Final destination for the /qr redirect.
|
|
98
|
+
/** Final destination for the /qr redirect. Optional on WhatsApp QUICK_REPLY
|
|
99
|
+
* buttons (the tap itself is tracked); required for email CTAs and URL buttons. */
|
|
99
100
|
target_url?: string;
|
|
101
|
+
/** Email CTA destination kind (feat-081 F2.5): external URL or a wa.me deep link. */
|
|
102
|
+
dest_type?: "external_url" | "whatsapp" | null;
|
|
103
|
+
/** WA channel whose number builds the wa.me link (dest_type='whatsapp'). */
|
|
104
|
+
wa_channel_id?: string | null;
|
|
105
|
+
/** Prefilled message for the wa.me link (dest_type='whatsapp'). */
|
|
106
|
+
wa_message?: string | null;
|
|
100
107
|
}
|
|
101
108
|
|
|
102
109
|
// ----- Pacing + ticket policy -----------------------------------------------
|
|
@@ -127,8 +134,12 @@ export interface ICampaignTicketPolicy {
|
|
|
127
134
|
export interface ICampaignMedia {
|
|
128
135
|
/** 'image' | 'video' | 'document' — WhatsApp header media type. */
|
|
129
136
|
type: string;
|
|
137
|
+
/** Full gs:// URI in WABA_MEDIA_BUCKET under tenants/<tenant>/ (feat-082/084 flow). */
|
|
130
138
|
gcs_path?: string;
|
|
131
139
|
url?: string;
|
|
140
|
+
/** Mime type of the uploaded media (drives the header component). */
|
|
141
|
+
mime_type?: string | null;
|
|
142
|
+
filename?: string | null;
|
|
132
143
|
}
|
|
133
144
|
|
|
134
145
|
// ----- Channel config -------------------------------------------------------
|
|
@@ -348,7 +359,10 @@ export type RecipientDispatchState =
|
|
|
348
359
|
| "pending"
|
|
349
360
|
| "dispatched"
|
|
350
361
|
| "done"
|
|
351
|
-
| "excluded"
|
|
362
|
+
| "excluded"
|
|
363
|
+
/** Campaign canceled with this recipient still pending (feat-081 F3 — formalizes
|
|
364
|
+
* what F2 stored as 'excluded'; readers must accept both on old docs). */
|
|
365
|
+
| "canceled";
|
|
352
366
|
|
|
353
367
|
/** Per-channel delivery status of a recipient (monotonic). */
|
|
354
368
|
export type RecipientChannelStatus =
|
|
@@ -15,7 +15,14 @@ export interface IAutomationCronTrigger {
|
|
|
15
15
|
export interface IAutomationWebhookTrigger {
|
|
16
16
|
type: "webhook";
|
|
17
17
|
}
|
|
18
|
-
export
|
|
18
|
+
export interface IAutomationEventTrigger {
|
|
19
|
+
type: "event";
|
|
20
|
+
event: {
|
|
21
|
+
types: string[];
|
|
22
|
+
actor_kinds?: Array<"user" | "system" | "automation">;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export type IAutomationTrigger = IAutomationCronTrigger | IAutomationWebhookTrigger | IAutomationEventTrigger;
|
|
19
26
|
export type AutomationDateOffsetMode = "calendar" | "business";
|
|
20
27
|
export interface IAutomationDateWindow {
|
|
21
28
|
offset_days: number;
|
|
@@ -36,7 +43,24 @@ export interface IAutomationAppointmentSelection {
|
|
|
36
43
|
payment_status_in?: string[];
|
|
37
44
|
};
|
|
38
45
|
}
|
|
39
|
-
export
|
|
46
|
+
export interface IAutomationLeadSelection {
|
|
47
|
+
target: "lead";
|
|
48
|
+
lead: {
|
|
49
|
+
status_in?: string[];
|
|
50
|
+
qualification_codes?: string[];
|
|
51
|
+
dist_channel_codes?: string[];
|
|
52
|
+
tag_names?: string[];
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
export interface IAutomationPatientSelection {
|
|
56
|
+
target: "patient";
|
|
57
|
+
patient: {
|
|
58
|
+
status_in?: string[];
|
|
59
|
+
source_codes?: string[];
|
|
60
|
+
tag_names?: string[];
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export type IAutomationSelection = IAutomationAppointmentSelection | IAutomationLeadSelection | IAutomationPatientSelection;
|
|
40
64
|
export interface IAutomationFilterValues {
|
|
41
65
|
professionals: string[];
|
|
42
66
|
procedures: string[];
|
|
@@ -48,7 +72,11 @@ export interface IAutomationFilterValues {
|
|
|
48
72
|
}
|
|
49
73
|
export declare const AUTOMATION_APPOINTMENT_FACTS: readonly ["appointment.status", "appointment.status_base", "appointment.appointment_type", "appointment.appointment_base_type", "appointment.appointment_mode", "appointment.professional_id", "appointment.procedure_ids", "appointment.professional_name", "appointment.procedure_names", "appointment.insurance_name", "appointment.address_name", "appointment.payment_status", "appointment.calendar_id"];
|
|
50
74
|
export type AutomationAppointmentFact = (typeof AUTOMATION_APPOINTMENT_FACTS)[number];
|
|
51
|
-
export
|
|
75
|
+
export declare const AUTOMATION_LEAD_FACTS: readonly ["lead.status", "lead.qualification_code", "lead.qualification_name", "lead.qualification_funnel_level", "lead.dist_channel_code", "lead.dist_channel_name", "lead.tags"];
|
|
76
|
+
export type AutomationLeadFact = (typeof AUTOMATION_LEAD_FACTS)[number];
|
|
77
|
+
export declare const AUTOMATION_PATIENT_FACTS: readonly ["patient.status", "patient.source_code", "patient.source_name", "patient.tags"];
|
|
78
|
+
export type AutomationPatientFact = (typeof AUTOMATION_PATIENT_FACTS)[number];
|
|
79
|
+
export type AutomationFact = AutomationAppointmentFact | AutomationLeadFact | AutomationPatientFact;
|
|
52
80
|
export declare const AutomationOperatorEnum: {
|
|
53
81
|
readonly Eq: "eq";
|
|
54
82
|
readonly Neq: "neq";
|
|
@@ -183,7 +211,9 @@ export interface IAutomationRunBranchCounts {
|
|
|
183
211
|
already_existed: number;
|
|
184
212
|
}
|
|
185
213
|
export interface IAutomationRunSample {
|
|
186
|
-
appointment_id
|
|
214
|
+
appointment_id?: string;
|
|
215
|
+
target_kind?: "appointment" | "lead" | "patient";
|
|
216
|
+
target_id?: string;
|
|
187
217
|
branch_id?: string;
|
|
188
218
|
decision: string;
|
|
189
219
|
task_id?: string;
|
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.AutomationRunStatusEnum = exports.AutomationOutputTypeEnum = exports.AutomationOperatorEnum = exports.AUTOMATION_APPOINTMENT_FACTS = exports.HubAutomationPermissions = void 0;
|
|
17
|
+
exports.AutomationRunStatusEnum = exports.AutomationOutputTypeEnum = exports.AutomationOperatorEnum = exports.AUTOMATION_PATIENT_FACTS = exports.AUTOMATION_LEAD_FACTS = exports.AUTOMATION_APPOINTMENT_FACTS = exports.HubAutomationPermissions = void 0;
|
|
18
18
|
__exportStar(require("./fb_collections"), exports);
|
|
19
19
|
// ======================================================
|
|
20
20
|
// hub-automation
|
|
@@ -60,6 +60,29 @@ exports.AUTOMATION_APPOINTMENT_FACTS = [
|
|
|
60
60
|
"appointment.payment_status",
|
|
61
61
|
"appointment.calendar_id",
|
|
62
62
|
];
|
|
63
|
+
// feat-085 (F3): lead domain facts (derived from the fields ILead exposes;
|
|
64
|
+
// resolved from the event-preloaded lead). Mirror of the appointment catalog.
|
|
65
|
+
exports.AUTOMATION_LEAD_FACTS = [
|
|
66
|
+
// 'active' | 'inactive' | 'draft'
|
|
67
|
+
"lead.status",
|
|
68
|
+
// qualification is a {code,name,funnelLevel} ref — surface all three.
|
|
69
|
+
"lead.qualification_code",
|
|
70
|
+
"lead.qualification_name",
|
|
71
|
+
"lead.qualification_funnel_level",
|
|
72
|
+
// distChannel is a {code,name} ref.
|
|
73
|
+
"lead.dist_channel_code",
|
|
74
|
+
"lead.dist_channel_name",
|
|
75
|
+
// string[] of tag names — matches if ANY tag name matches.
|
|
76
|
+
"lead.tags",
|
|
77
|
+
];
|
|
78
|
+
// feat-085 (F3): patient domain facts (derived from IPatient).
|
|
79
|
+
exports.AUTOMATION_PATIENT_FACTS = [
|
|
80
|
+
"patient.status",
|
|
81
|
+
"patient.source_code",
|
|
82
|
+
"patient.source_name",
|
|
83
|
+
// string[] of tag names — matches if ANY tag name matches.
|
|
84
|
+
"patient.tags",
|
|
85
|
+
];
|
|
63
86
|
// ------------------------------------------------------
|
|
64
87
|
// Conditions (recursive AND/OR groups)
|
|
65
88
|
// ------------------------------------------------------
|
|
@@ -45,9 +45,25 @@ export interface IAutomationWebhookTrigger {
|
|
|
45
45
|
type: "webhook";
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
// feat-085 (F1): fired by a domain event (evo-events). The subscriber
|
|
49
|
+
// (hub_automation_events) glob-matches `event.types` against IDomainEvent.type
|
|
50
|
+
// and discards events whose actor.kind is not in `actor_kinds` (default
|
|
51
|
+
// ['user'] — cuts the automation self-loop; opt-in 'system'/'automation').
|
|
52
|
+
export interface IAutomationEventTrigger {
|
|
53
|
+
type: "event";
|
|
54
|
+
event: {
|
|
55
|
+
// Glob patterns matched against IDomainEvent.type (matcher: 'agendamento.*',
|
|
56
|
+
// 'agendamento.reagendado', '*').
|
|
57
|
+
types: string[];
|
|
58
|
+
// Allowlist of originating actor kinds. Default (omitted) = ['user'].
|
|
59
|
+
actor_kinds?: Array<"user" | "system" | "automation">;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
48
63
|
export type IAutomationTrigger =
|
|
49
64
|
| IAutomationCronTrigger
|
|
50
|
-
| IAutomationWebhookTrigger
|
|
65
|
+
| IAutomationWebhookTrigger
|
|
66
|
+
| IAutomationEventTrigger;
|
|
51
67
|
|
|
52
68
|
// ------------------------------------------------------
|
|
53
69
|
// Selection (F1: appointment target only)
|
|
@@ -93,7 +109,36 @@ export interface IAutomationAppointmentSelection {
|
|
|
93
109
|
};
|
|
94
110
|
}
|
|
95
111
|
|
|
96
|
-
|
|
112
|
+
// feat-085 (F3): lead/patient selections. Cron selection is appointment-only;
|
|
113
|
+
// these targets only arrive via the domain-event trigger, where the consumer
|
|
114
|
+
// PRE-LOADS the single target from the event (the `lead`/`patient` filters below
|
|
115
|
+
// are therefore not enforced at event runtime — they exist so a routine can be
|
|
116
|
+
// authored/validated with a lead/patient target and, later, for a possible
|
|
117
|
+
// lead/patient sweep). Discriminated by `target`.
|
|
118
|
+
export interface IAutomationLeadSelection {
|
|
119
|
+
target: "lead";
|
|
120
|
+
lead: {
|
|
121
|
+
// Reserved narrowing filters (glob-aware like the appointment filters).
|
|
122
|
+
status_in?: string[];
|
|
123
|
+
qualification_codes?: string[];
|
|
124
|
+
dist_channel_codes?: string[];
|
|
125
|
+
tag_names?: string[];
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export interface IAutomationPatientSelection {
|
|
130
|
+
target: "patient";
|
|
131
|
+
patient: {
|
|
132
|
+
status_in?: string[];
|
|
133
|
+
source_codes?: string[];
|
|
134
|
+
tag_names?: string[];
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export type IAutomationSelection =
|
|
139
|
+
| IAutomationAppointmentSelection
|
|
140
|
+
| IAutomationLeadSelection
|
|
141
|
+
| IAutomationPatientSelection;
|
|
97
142
|
|
|
98
143
|
// Distinct filter values for a calendar, built from a limited window of local
|
|
99
144
|
// appointments (GET /routines/filter-values?calendar_id=). Feeds the GUI's
|
|
@@ -137,7 +182,39 @@ export const AUTOMATION_APPOINTMENT_FACTS = [
|
|
|
137
182
|
export type AutomationAppointmentFact =
|
|
138
183
|
(typeof AUTOMATION_APPOINTMENT_FACTS)[number];
|
|
139
184
|
|
|
140
|
-
|
|
185
|
+
// feat-085 (F3): lead domain facts (derived from the fields ILead exposes;
|
|
186
|
+
// resolved from the event-preloaded lead). Mirror of the appointment catalog.
|
|
187
|
+
export const AUTOMATION_LEAD_FACTS = [
|
|
188
|
+
// 'active' | 'inactive' | 'draft'
|
|
189
|
+
"lead.status",
|
|
190
|
+
// qualification is a {code,name,funnelLevel} ref — surface all three.
|
|
191
|
+
"lead.qualification_code",
|
|
192
|
+
"lead.qualification_name",
|
|
193
|
+
"lead.qualification_funnel_level",
|
|
194
|
+
// distChannel is a {code,name} ref.
|
|
195
|
+
"lead.dist_channel_code",
|
|
196
|
+
"lead.dist_channel_name",
|
|
197
|
+
// string[] of tag names — matches if ANY tag name matches.
|
|
198
|
+
"lead.tags",
|
|
199
|
+
] as const;
|
|
200
|
+
|
|
201
|
+
export type AutomationLeadFact = (typeof AUTOMATION_LEAD_FACTS)[number];
|
|
202
|
+
|
|
203
|
+
// feat-085 (F3): patient domain facts (derived from IPatient).
|
|
204
|
+
export const AUTOMATION_PATIENT_FACTS = [
|
|
205
|
+
"patient.status",
|
|
206
|
+
"patient.source_code",
|
|
207
|
+
"patient.source_name",
|
|
208
|
+
// string[] of tag names — matches if ANY tag name matches.
|
|
209
|
+
"patient.tags",
|
|
210
|
+
] as const;
|
|
211
|
+
|
|
212
|
+
export type AutomationPatientFact = (typeof AUTOMATION_PATIENT_FACTS)[number];
|
|
213
|
+
|
|
214
|
+
export type AutomationFact =
|
|
215
|
+
| AutomationAppointmentFact
|
|
216
|
+
| AutomationLeadFact
|
|
217
|
+
| AutomationPatientFact;
|
|
141
218
|
|
|
142
219
|
// ------------------------------------------------------
|
|
143
220
|
// Conditions (recursive AND/OR groups)
|
|
@@ -362,7 +439,12 @@ export interface IAutomationRunBranchCounts {
|
|
|
362
439
|
}
|
|
363
440
|
|
|
364
441
|
export interface IAutomationRunSample {
|
|
365
|
-
|
|
442
|
+
// feat-085 (F3): a run target may now be an appointment, a lead or a patient.
|
|
443
|
+
// `appointment_id` is kept (still set for appointment targets) for backward
|
|
444
|
+
// compatibility; `target_kind`/`target_id` are the domain-agnostic identity.
|
|
445
|
+
appointment_id?: string;
|
|
446
|
+
target_kind?: "appointment" | "lead" | "patient";
|
|
447
|
+
target_id?: string;
|
|
366
448
|
branch_id?: string;
|
|
367
449
|
// e.g. 'created' | 'already_existed' | 'not_matched' | 'suppressed_by_limit'
|
|
368
450
|
decision: string;
|
|
@@ -11,6 +11,8 @@ export declare const ExternalObjectTypeEnum: {
|
|
|
11
11
|
* desfecho do envio (sent/failed + os codes da feat-072).
|
|
12
12
|
*/
|
|
13
13
|
readonly EvoTask: "evo_task";
|
|
14
|
+
/** Campanha do hub-omni (feat-081) — liga mensagens/tickets à campanha que os originou. */
|
|
15
|
+
readonly Campaign: "campaign";
|
|
14
16
|
/** Nexus FinOps billing document */
|
|
15
17
|
readonly NexBilling: "nex_billing";
|
|
16
18
|
readonly NexContract: "nex_contract";
|
|
@@ -15,6 +15,8 @@ exports.ExternalObjectTypeEnum = {
|
|
|
15
15
|
* desfecho do envio (sent/failed + os codes da feat-072).
|
|
16
16
|
*/
|
|
17
17
|
EvoTask: "evo_task",
|
|
18
|
+
/** Campanha do hub-omni (feat-081) — liga mensagens/tickets à campanha que os originou. */
|
|
19
|
+
Campaign: "campaign",
|
|
18
20
|
/** Nexus FinOps billing document */
|
|
19
21
|
NexBilling: "nex_billing",
|
|
20
22
|
NexContract: "nex_contract",
|
|
@@ -15,6 +15,8 @@ export const ExternalObjectTypeEnum = {
|
|
|
15
15
|
* desfecho do envio (sent/failed + os codes da feat-072).
|
|
16
16
|
*/
|
|
17
17
|
EvoTask: "evo_task",
|
|
18
|
+
/** Campanha do hub-omni (feat-081) — liga mensagens/tickets à campanha que os originou. */
|
|
19
|
+
Campaign: "campaign",
|
|
18
20
|
/** Nexus FinOps billing document */
|
|
19
21
|
NexBilling: "nex_billing",
|
|
20
22
|
NexContract: "nex_contract",
|