@trii/types 3.0.0-preview.1 → 3.0.0-preview.3

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.
Files changed (139) hide show
  1. package/dist/Common/Messages/EmailQueue.d.ts +53 -0
  2. package/dist/Common/Messages/EmailQueue.js +41 -0
  3. package/dist/Common/Messages/EmailUnsubscribe.d.ts +19 -0
  4. package/dist/Common/Messages/EmailUnsubscribe.js +61 -0
  5. package/dist/Common/Messages/Message.d.ts +213 -45
  6. package/dist/Common/Messages/Message.js +45 -1
  7. package/dist/Common/Messages/MessageIdentityIndex.d.ts +19 -0
  8. package/dist/Common/Messages/MessageModel.d.ts +72 -0
  9. package/dist/Common/Messages/MessageModel.js +56 -0
  10. package/dist/Common/Messages/SendOperation.d.ts +157 -0
  11. package/dist/Common/Messages/SendOperation.js +17 -0
  12. package/dist/Common/Messages/index.d.ts +5 -0
  13. package/dist/Common/Messages/index.js +5 -0
  14. package/dist/Common/Notifications/UserNotificationsConfig.d.ts +6 -0
  15. package/dist/Common/Notifications/UserNotificationsConfig.js +2 -0
  16. package/dist/Common/Variables.d.ts +22 -0
  17. package/dist/Common/Variables.js +7 -0
  18. package/dist/Common/index.d.ts +1 -0
  19. package/dist/Common/index.js +2 -1
  20. package/dist/Contacts/BusinessModel.d.ts +53 -0
  21. package/dist/Contacts/BusinessModel.js +10 -0
  22. package/dist/Contacts/ChannelIdentityModel.d.ts +116 -0
  23. package/dist/Contacts/ChannelIdentityModel.js +54 -0
  24. package/dist/Contacts/IdentityErrors.d.ts +42 -0
  25. package/dist/Contacts/IdentityErrors.js +10 -0
  26. package/dist/Contacts/IdentityEvents.d.ts +60 -0
  27. package/dist/Contacts/IdentityPolicyChange.d.ts +51 -0
  28. package/dist/Contacts/IdentityPolicyChange.js +12 -0
  29. package/dist/Contacts/Note.d.ts +24 -0
  30. package/dist/Contacts/Note.js +2 -0
  31. package/dist/Contacts/contacts.d.ts +96 -31
  32. package/dist/Contacts/contacts.js +2 -0
  33. package/dist/Contacts/index.d.ts +5 -0
  34. package/dist/Contacts/index.js +5 -0
  35. package/dist/Conversations/Conversation.d.ts +41 -4
  36. package/dist/Conversations/Conversation.js +5 -1
  37. package/dist/Conversations/ConversationAssociationEvents.d.ts +22 -0
  38. package/dist/Conversations/ConversationAssociationEvents.js +8 -0
  39. package/dist/Conversations/index.d.ts +1 -0
  40. package/dist/Conversations/index.js +1 -0
  41. package/dist/Marketing/Subscriber.d.ts +34 -2
  42. package/dist/Media/MediaApi.d.ts +51 -0
  43. package/dist/Media/MediaAsset.d.ts +162 -0
  44. package/dist/Media/MediaAsset.js +66 -0
  45. package/dist/Media/index.d.ts +2 -0
  46. package/dist/Media/index.js +18 -0
  47. package/dist/Spaces/WorkspaceSecurityPolicy.d.ts +10 -0
  48. package/dist/Spaces/index.d.ts +1 -0
  49. package/dist/Spaces/index.js +1 -0
  50. package/dist/Spaces/spaces.d.ts +14 -0
  51. package/dist/Tickets/Task.d.ts +11 -0
  52. package/dist/Tickets/Ticket.d.ts +6 -1
  53. package/dist/index.d.ts +1 -0
  54. package/dist/index.js +2 -1
  55. package/package.json +4 -2
  56. package/dist/AI/MapPolygon.d.ts +0 -22
  57. package/dist/Conversations/ConversationAutoCloseSettings.d.ts +0 -17
  58. package/dist/Conversations/ConversationAutoCloseSettings.js +0 -5
  59. package/dist/Conversations/DashBoard/dashboardForms.d.ts +0 -44
  60. package/dist/Conversations/DashBoard/dashboardForms.js +0 -24
  61. package/dist/Conversations/Flows/Nodes/NodeAIChatBot.d.ts +0 -0
  62. package/dist/Conversations/Flows/Nodes/NodeAIChatBot.js +0 -0
  63. package/dist/Conversations/Flows/Nodes/NodeApi.d.ts +0 -2
  64. package/dist/Conversations/Flows/Nodes/NodeApi.js +0 -183
  65. package/dist/Conversations/Flows/Nodes/NodeBotIA.d.ts +0 -15
  66. package/dist/Conversations/Flows/Nodes/NodeBotIA.js +0 -6
  67. package/dist/Conversations/Flows/Nodes/NodeChatBotIA.d.ts +0 -15
  68. package/dist/Conversations/Flows/Nodes/NodeChatBotIA.js +0 -6
  69. package/dist/Conversations/Flows/Nodes/NodeConditional.d.ts +0 -0
  70. package/dist/Conversations/Flows/Nodes/NodeConditional.js +0 -0
  71. package/dist/Conversations/Flows/Nodes/NodeContactSearch.d.ts +0 -0
  72. package/dist/Conversations/Flows/Nodes/NodeContactSearch.js +0 -0
  73. package/dist/Conversations/Flows/Nodes/NodeContactUpdate.d.ts +0 -0
  74. package/dist/Conversations/Flows/Nodes/NodeContactUpdate.js +0 -0
  75. package/dist/Conversations/Flows/Nodes/NodeConversationAssignTo.d.ts +0 -0
  76. package/dist/Conversations/Flows/Nodes/NodeConversationAssignTo.js +0 -0
  77. package/dist/Conversations/Flows/Nodes/NodeConversationFinalize.d.ts +0 -0
  78. package/dist/Conversations/Flows/Nodes/NodeConversationFinalize.js +0 -0
  79. package/dist/Conversations/Flows/Nodes/NodeConversationUpdate.d.ts +0 -0
  80. package/dist/Conversations/Flows/Nodes/NodeConversationUpdate.js +0 -0
  81. package/dist/Conversations/Flows/Nodes/NodeFillForm.d.ts +0 -0
  82. package/dist/Conversations/Flows/Nodes/NodeFillForm.js +0 -0
  83. package/dist/Conversations/Flows/Nodes/NodeFillTicket.d.ts +0 -1
  84. package/dist/Conversations/Flows/Nodes/NodeFillTicket.js +0 -9
  85. package/dist/Conversations/Flows/Nodes/NodeGoogleCalendar.d.ts +0 -20
  86. package/dist/Conversations/Flows/Nodes/NodeGoogleMaps copy.d.ts +0 -12
  87. package/dist/Conversations/Flows/Nodes/NodeGoogleMaps copy.js +0 -6
  88. package/dist/Conversations/Flows/Nodes/NodeGoogleMaps.d.ts +0 -15
  89. package/dist/Conversations/Flows/Nodes/NodeMsgReply.d.ts +0 -0
  90. package/dist/Conversations/Flows/Nodes/NodeMsgReply.js +0 -0
  91. package/dist/Conversations/Flows/Nodes/NodeMsgSend.d.ts +0 -0
  92. package/dist/Conversations/Flows/Nodes/NodeMsgSend.js +0 -0
  93. package/dist/Conversations/Flows/Nodes/NodeMsgText.d.ts +0 -1
  94. package/dist/Conversations/Flows/Nodes/NodeMsgText.js +0 -27
  95. package/dist/Conversations/Flows/Nodes/NodeMsgWaitResponse.d.ts +0 -0
  96. package/dist/Conversations/Flows/Nodes/NodeMsgWaitResponse.js +0 -0
  97. package/dist/Conversations/Flows/Nodes/NodeRedirect.d.ts +0 -0
  98. package/dist/Conversations/Flows/Nodes/NodeRedirect.js +0 -0
  99. package/dist/Conversations/Flows/Nodes/NodeSendEmail.d.ts +0 -0
  100. package/dist/Conversations/Flows/Nodes/NodeSendEmail.js +0 -0
  101. package/dist/Conversations/Flows/Nodes/NodeSqlQuery.d.ts +0 -0
  102. package/dist/Conversations/Flows/Nodes/NodeSqlQuery.js +0 -0
  103. package/dist/Conversations/Flows/Nodes/NodeStart.d.ts +0 -0
  104. package/dist/Conversations/Flows/Nodes/NodeStart.js +0 -0
  105. package/dist/Conversations/Flows/Nodes/NodeTimeScheduleControl.d.ts +0 -0
  106. package/dist/Conversations/Flows/Nodes/NodeTimeScheduleControl.js +0 -0
  107. package/dist/Conversations/Flows/Nodes/NodeTimeTimer.d.ts +0 -0
  108. package/dist/Conversations/Flows/Nodes/NodeTimeTimer.js +0 -0
  109. package/dist/Conversations/Flows/Nodes/NodeTimeWaitUntil.d.ts +0 -0
  110. package/dist/Conversations/Flows/Nodes/NodeTimeWaitUntil.js +0 -0
  111. package/dist/Conversations/Flows/Nodes/NodeToolCalculator.d.ts +0 -2
  112. package/dist/Conversations/Flows/Nodes/NodeToolCalculator.js +0 -37
  113. package/dist/Conversations/Flows/Nodes/NodeToolContacts.d.ts +0 -2
  114. package/dist/Conversations/Flows/Nodes/NodeToolContacts.js +0 -59
  115. package/dist/Conversations/Flows/Nodes/NodeToolFunction.d.ts +0 -2
  116. package/dist/Conversations/Flows/Nodes/NodeToolFunction.js +0 -45
  117. package/dist/Conversations/Flows/Nodes/NodeToolGoogleCalendar.d.ts +0 -2
  118. package/dist/Conversations/Flows/Nodes/NodeToolGoogleCalendar.js +0 -87
  119. package/dist/Conversations/Flows/Nodes/NodeToolGoogleMaps.d.ts +0 -1
  120. package/dist/Conversations/Flows/Nodes/NodeToolKnowledge.d.ts +0 -2
  121. package/dist/Conversations/Flows/Nodes/NodeToolKnowledge.js +0 -52
  122. package/dist/Conversations/Flows/Nodes/NodeToolMapsCheckPolygon.d.ts +0 -2
  123. package/dist/Conversations/Flows/Nodes/NodeToolMapsCheckPolygon.js +0 -59
  124. package/dist/Conversations/Flows/Nodes/NodeToolMcpClient.d.ts +0 -2
  125. package/dist/Conversations/Flows/Nodes/NodeToolMcpClient.js +0 -45
  126. package/dist/Conversations/Flows/Nodes/NodeToolShoppingCart.d.ts +0 -2
  127. package/dist/Conversations/Flows/Nodes/NodeToolShoppingCart.js +0 -81
  128. package/dist/Conversations/Flows/Nodes/index.d.ts +0 -24
  129. package/dist/Conversations/Flows/Nodes/index.js +0 -40
  130. package/dist/Conversations/InboxCounters.d.ts +0 -18
  131. package/dist/Conversations/InboxCounters.js +0 -2
  132. package/dist/Presence/ChannelRoutingState.d.ts +0 -17
  133. package/dist/Presence/ChannelRoutingState.js +0 -9
  134. package/dist/Tickets/AccessLevel.d.ts +0 -5
  135. package/dist/Tickets/AccessLevel.js +0 -9
  136. /package/dist/{AI/MapPolygon.js → Common/Messages/MessageIdentityIndex.js} +0 -0
  137. /package/dist/{Conversations/Flows/Nodes/NodeGoogleCalendar.js → Contacts/IdentityEvents.js} +0 -0
  138. /package/dist/{Conversations/Flows/Nodes/NodeGoogleMaps.js → Media/MediaApi.js} +0 -0
  139. /package/dist/{Conversations/Flows/Nodes/NodeToolGoogleMaps.js → Spaces/WorkspaceSecurityPolicy.js} +0 -0
@@ -0,0 +1,72 @@
1
+ import type { MessageMedia, MessageTemplateVar } from "./Message";
2
+ /** Circuito del mensaje (plan §15.17 MS1). conversationId obligatorio solo en interaction e internal_chat. */
3
+ export type MessageCircuit = 'interaction' | 'internal_chat' | 'campaign' | 'call' | 'system' | 'unknown';
4
+ /** Qué contenido tiene el mensaje (MS2). Lista cerrada; unknown solo en históricos. */
5
+ export type MessageKind = 'text' | 'image' | 'video' | 'audio' | 'document' | 'sticker' | 'location' | 'contact' | 'email' | 'call' | 'poll' | 'form' | 'event' | 'ticket' | 'info' | 'note' | 'comment' | 'interaction' | 'template' | 'unknown';
6
+ export type MessageParticipantRole = 'from' | 'to' | 'cc' | 'bcc';
7
+ /** Participante observado (MS4, C04). Evidencia inmutable. BCC se filtra por permiso al leer. */
8
+ export interface MessageParticipant {
9
+ role: MessageParticipantRole;
10
+ /** Todas las claves observadas (formato namespace|scope|valor). */
11
+ keys: string[];
12
+ /** La de mayor prioridad; la que va a MessageIdentityIndex. */
13
+ indexedKey: string;
14
+ normalizationVersion: number;
15
+ channelIdentityId?: string | null;
16
+ /** Nombre tal como vino en el mensaje. */
17
+ displayName?: string | null;
18
+ /** Valor original sin normalizar. */
19
+ rawValue?: string | null;
20
+ }
21
+ export type MessageDeliveryStatus = 'queued' | 'sent' | 'delivered' | 'bounced' | 'failed' | 'read';
22
+ /** Estado de entrega por destinatario externo (MS5). IMessage.ack es el resumen. */
23
+ export interface MessageDelivery {
24
+ /** indexedKey del participante destinatario. */
25
+ participantKey: string;
26
+ status: MessageDeliveryStatus;
27
+ providerMessageId?: string | null;
28
+ error?: string | null;
29
+ updatedAt: Date;
30
+ }
31
+ /** Destinatario de email del modelo nuevo (§14.2, MS7). Convive con MessageEmail.to/cc/bcc hasta E7. */
32
+ export interface EmailRecipient {
33
+ address: string;
34
+ name?: string | null;
35
+ channelIdentityId?: string | null;
36
+ }
37
+ /**
38
+ * Plantilla con la que se envió el mensaje (§15.17.2 MT1). El contenido armado (text, header, buttons, footer,
39
+ * locations[0]) es lo que muestra el historial; esto es la evidencia del envío. Los template* sueltos de IMessage
40
+ * se escriben desde este objeto hasta E7.
41
+ */
42
+ export interface MessageTemplate {
43
+ templateId: string;
44
+ name: string;
45
+ /** Copia de Template.language al enviar. */
46
+ language?: string | null;
47
+ /** Copia de Template.category al enviar. */
48
+ category?: string | null;
49
+ headerVars: MessageTemplateVar[];
50
+ bodyVars: MessageTemplateVar[];
51
+ /** Identificadas por btnNumber de la plantilla, nunca por posición (MT2). */
52
+ buttonVars: MessageTemplateButtonVar[];
53
+ /** @deprecated URL legacy del encabezado; usar media (MD7/MD16). */
54
+ mediaUrl?: string | null;
55
+ /** Archivo en MediaAssets (§15.27 MD16); lo llenan los writers nuevos y la URL se firma al leer. */
56
+ media?: MessageMedia | null;
57
+ }
58
+ /** Variable de un botón de plantilla (MT2). */
59
+ export interface MessageTemplateButtonVar {
60
+ /** TemplateButton.btnNumber. */
61
+ btnNumber: number;
62
+ var?: string | null;
63
+ value: string;
64
+ }
65
+ /** type legacy derivado de circuit + kind (MS3/R04). CDR_PBX, N2B y NOTIFICATION_NEW_CONVERSATION ya no se escriben. */
66
+ export declare function messageTypeFor(circuit: MessageCircuit, kind: MessageKind): number;
67
+ /** Estado de entrega por destinatario → valor de MessageAck. */
68
+ export declare function messageAckFor(status: MessageDeliveryStatus): number;
69
+ /** Resumen de ack (R03): el menos avanzado entre los que no fallaron; ACK_ERROR solo si fallaron todos. */
70
+ export declare function messageSummaryAck(deliveries: Pick<MessageDelivery, 'status'>[]): number;
71
+ /** Destinatarios con error (failed o bounced), para «1 de 3 con error». */
72
+ export declare function messageFailedCount(deliveries: Pick<MessageDelivery, 'status'>[]): number;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.messageTypeFor = messageTypeFor;
4
+ exports.messageAckFor = messageAckFor;
5
+ exports.messageSummaryAck = messageSummaryAck;
6
+ exports.messageFailedCount = messageFailedCount;
7
+ /**
8
+ * Funciones comunes del contrato Message (§15.17, MS3/R04 y R03), espejo de Trii.Common.Messages.MessageContract.
9
+ * Valores numéricos de MessageType y MessageAck.
10
+ */
11
+ const MESSAGE_TYPE = { CHAT: 1, CHAT_EXTERNAL: 2, NOTE: 3, CALL: 5, COMMENT: 6, INFO: 7, ACTIVITY: 14 };
12
+ const MESSAGE_ACK = { ACK_QUEUE: -2, ACK_ERROR: 1, ACK_SERVER: 2, ACK_DEVICE: 3, ACK_READ: 4 };
13
+ /** type legacy derivado de circuit + kind (MS3/R04). CDR_PBX, N2B y NOTIFICATION_NEW_CONVERSATION ya no se escriben. */
14
+ function messageTypeFor(circuit, kind) {
15
+ switch (circuit) {
16
+ case 'interaction':
17
+ if (kind === 'note')
18
+ return MESSAGE_TYPE.NOTE;
19
+ if (kind === 'info')
20
+ return MESSAGE_TYPE.INFO;
21
+ if (kind === 'ticket')
22
+ return MESSAGE_TYPE.ACTIVITY;
23
+ if (kind === 'comment')
24
+ return MESSAGE_TYPE.COMMENT;
25
+ return MESSAGE_TYPE.CHAT_EXTERNAL;
26
+ case 'internal_chat':
27
+ return kind === 'info' ? MESSAGE_TYPE.INFO : MESSAGE_TYPE.CHAT;
28
+ case 'campaign': return MESSAGE_TYPE.CHAT_EXTERNAL;
29
+ case 'call': return MESSAGE_TYPE.CALL;
30
+ case 'system': return MESSAGE_TYPE.INFO;
31
+ default: throw new Error(`circuit no admitido en escrituras: ${circuit}`);
32
+ }
33
+ }
34
+ /** Estado de entrega por destinatario → valor de MessageAck. */
35
+ function messageAckFor(status) {
36
+ switch (status) {
37
+ case 'queued': return MESSAGE_ACK.ACK_QUEUE;
38
+ case 'sent': return MESSAGE_ACK.ACK_SERVER;
39
+ case 'delivered': return MESSAGE_ACK.ACK_DEVICE;
40
+ case 'read': return MESSAGE_ACK.ACK_READ;
41
+ case 'bounced':
42
+ case 'failed': return MESSAGE_ACK.ACK_ERROR;
43
+ default: throw new Error(`estado de entrega desconocido: ${status}`);
44
+ }
45
+ }
46
+ /** Resumen de ack (R03): el menos avanzado entre los que no fallaron; ACK_ERROR solo si fallaron todos. */
47
+ function messageSummaryAck(deliveries) {
48
+ if (deliveries.length === 0)
49
+ throw new Error('sin entregas');
50
+ const ok = deliveries.map(d => messageAckFor(d.status)).filter(a => a !== MESSAGE_ACK.ACK_ERROR);
51
+ return ok.length ? Math.min(...ok) : MESSAGE_ACK.ACK_ERROR;
52
+ }
53
+ /** Destinatarios con error (failed o bounced), para «1 de 3 con error». */
54
+ function messageFailedCount(deliveries) {
55
+ return deliveries.filter(d => d.status === 'failed' || d.status === 'bounced').length;
56
+ }
@@ -0,0 +1,157 @@
1
+ import type { EmailRecipient, MessageCircuit } from './MessageModel';
2
+ import type { MessageMedia } from './Message';
3
+ /** Colecciones de la base Messages (§15.22). */
4
+ export declare const MESSAGE_COLLECTIONS: {
5
+ readonly SendOperations: "SendOperations";
6
+ /** Outbox único de la base Messages (EV4). */
7
+ readonly Outbox: "Outbox";
8
+ };
9
+ /** Estados de una operación de envío (SO1). unknown se reconcilia antes de repetir. */
10
+ export type SendOperationStatus = 'accepted' | 'scheduled' | 'executing' | 'sent' | 'partially_failed' | 'failed' | 'unknown' | 'canceled';
11
+ /**
12
+ * sent = el proveedor aceptó el envío (no entrega ni lectura). sent, partially_failed, failed y canceled son terminales;
13
+ * unknown no. Los avisos de entrega posteriores no cambian la operación ni reinician la idempotencia.
14
+ */
15
+ export declare function isTerminalSendOperationStatus(status: SendOperationStatus): boolean;
16
+ /** Tipo de redacción (SO5). reply_all lo arma el front, nunca con CCO. */
17
+ export type EmailCompositionType = 'new' | 'reply' | 'forward';
18
+ /** Adjunto por referencia autorizada (SO4, actualizado por MD1): MediaAsset del espacio en estado ready. Sin URLs. */
19
+ export interface EmailAttachmentRef {
20
+ mediaAssetId: string;
21
+ /** @deprecated Legacy de SO4 antes de MediaAssets; usar mediaAssetId. */
22
+ blobName?: string | null;
23
+ filename: string;
24
+ mimeType: string;
25
+ isInline: boolean;
26
+ contentId?: string | null;
27
+ }
28
+ /** Pedido de POST /api/v2/messages/{spaceId}/Emails (header Idempotency-Key obligatorio). */
29
+ export interface SendEmailRequest {
30
+ channelId: string;
31
+ compositionType: EmailCompositionType;
32
+ /** Solo reply. */
33
+ conversationId?: string | null;
34
+ /** Solo reply. */
35
+ inReplyToMessageId?: string | null;
36
+ to: EmailRecipient[];
37
+ cc: EmailRecipient[];
38
+ bcc: EmailRecipient[];
39
+ subject: string;
40
+ bodyHtml: string;
41
+ bodyText?: string | null;
42
+ attachments: EmailAttachmentRef[];
43
+ /** Envío programado; null = inmediato. La interacción se crea al ejecutar. */
44
+ scheduledAt?: Date | null;
45
+ }
46
+ /**
47
+ * Email persistido en la operación (T01): como SendEmailRequest pero sin cuerpo inline; el cuerpo está en el MediaAsset
48
+ * email_body y Message.email.body apunta al mismo asset al ejecutar.
49
+ */
50
+ export interface SendOperationEmail {
51
+ channelId: string;
52
+ compositionType: EmailCompositionType;
53
+ conversationId?: string | null;
54
+ inReplyToMessageId?: string | null;
55
+ to: EmailRecipient[];
56
+ cc: EmailRecipient[];
57
+ /** CCO: se filtra por permiso al proyectar (U8, SO11). */
58
+ bcc: EmailRecipient[];
59
+ subject: string;
60
+ /** Cuerpo en MediaAsset email_body; en GET, access firmado al leer. */
61
+ body: MessageMedia;
62
+ snippet?: string | null;
63
+ attachments: EmailAttachmentRef[];
64
+ scheduledAt?: Date | null;
65
+ }
66
+ /** Operación de envío (colección SendOperations, SO1). */
67
+ export interface SendOperation {
68
+ operationId: string;
69
+ spaceId: string;
70
+ actor: string;
71
+ idempotencyKey: string;
72
+ /** Hash del POST original; inmutable (Q01). */
73
+ requestHash: string;
74
+ channelType: number;
75
+ channelId: string;
76
+ /** Circuito del envío (Q02). */
77
+ circuit: MessageCircuit;
78
+ status: SendOperationStatus;
79
+ version: number;
80
+ scheduledAt?: Date | null;
81
+ email?: SendOperationEmail | null;
82
+ messageId?: string | null;
83
+ messageShardKey?: string | null;
84
+ conversationId?: string | null;
85
+ /** Entero de 64 bits como texto decimal (F01): no convertir a number. */
86
+ scheduledSequenceNumber?: string | null;
87
+ scheduledQueue?: string | null;
88
+ createdAt: Date;
89
+ updatedAt: Date;
90
+ completedAt?: Date | null;
91
+ idempotencyExpiresAt?: Date | null;
92
+ attempts: number;
93
+ lastError?: string | null;
94
+ }
95
+ /** Respuesta 202 del POST y de las acciones sobre la operación (SO6). */
96
+ export interface SendOperationResponse {
97
+ operationId: string;
98
+ status: SendOperationStatus;
99
+ version: number;
100
+ messageId?: string | null;
101
+ conversationId?: string | null;
102
+ }
103
+ /** Proyección pública del GET (Q03): sin clave/hash, datos de cola ni error técnico; CCO solo con permiso. */
104
+ export interface SendOperationDetail {
105
+ operationId: string;
106
+ status: SendOperationStatus;
107
+ version: number;
108
+ circuit: MessageCircuit;
109
+ channelType: number;
110
+ channelId: string;
111
+ scheduledAt?: Date | null;
112
+ email?: SendOperationEmail | null;
113
+ messageId?: string | null;
114
+ conversationId?: string | null;
115
+ createdAt: Date;
116
+ updatedAt: Date;
117
+ completedAt?: Date | null;
118
+ }
119
+ /** Contenido nuevo del email en una edición (SO3): igual que SendEmailRequest pero sin bcc (SO11, F01 de 84). */
120
+ export interface UpdateEmailContent {
121
+ channelId: string;
122
+ compositionType: EmailCompositionType;
123
+ conversationId?: string | null;
124
+ inReplyToMessageId?: string | null;
125
+ to: EmailRecipient[];
126
+ cc: EmailRecipient[];
127
+ subject: string;
128
+ bodyHtml: string;
129
+ bodyText?: string | null;
130
+ attachments: EmailAttachmentRef[];
131
+ scheduledAt?: Date | null;
132
+ }
133
+ /** Cambio explícito de CCO en una edición (SO11). Exige permiso para ver CCO; recipients vacío los quita. */
134
+ export interface BccChange {
135
+ recipients: EmailRecipient[];
136
+ }
137
+ /**
138
+ * PUT .../SendOperations/{operationId} (SO3/SO11). bccChange ausente o null = se conservan los CCO guardados (lo normal
139
+ * para un usuario sin permiso). Presente sin permiso = rechazo. Presente con permiso = reemplaza la lista.
140
+ */
141
+ export interface UpdateSendOperationRequest {
142
+ expectedVersion: number;
143
+ email?: UpdateEmailContent | null;
144
+ bccChange?: BccChange | null;
145
+ }
146
+ export type SendOperationEventType = 'send_operation.status_changed' | 'send_operation.updated';
147
+ /** Payload de send_operation.* (aggregateVersion = SendOperation.version). */
148
+ export interface SendOperationEventPayload {
149
+ operationId: string;
150
+ status: SendOperationStatus;
151
+ previousStatus?: SendOperationStatus | null;
152
+ messageId?: string | null;
153
+ conversationId?: string | null;
154
+ actor: string;
155
+ occurredAt: Date;
156
+ aggregateVersion: number;
157
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MESSAGE_COLLECTIONS = void 0;
4
+ exports.isTerminalSendOperationStatus = isTerminalSendOperationStatus;
5
+ /** Colecciones de la base Messages (§15.22). */
6
+ exports.MESSAGE_COLLECTIONS = {
7
+ SendOperations: 'SendOperations',
8
+ /** Outbox único de la base Messages (EV4). */
9
+ Outbox: 'Outbox',
10
+ };
11
+ /**
12
+ * sent = el proveedor aceptó el envío (no entrega ni lectura). sent, partially_failed, failed y canceled son terminales;
13
+ * unknown no. Los avisos de entrega posteriores no cambian la operación ni reinician la idempotencia.
14
+ */
15
+ function isTerminalSendOperationStatus(status) {
16
+ return status === 'sent' || status === 'partially_failed' || status === 'failed' || status === 'canceled';
17
+ }
@@ -1,3 +1,8 @@
1
1
  export * from "./Message";
2
2
  export * from "./MediaFile";
3
3
  export * from "./Template";
4
+ export * from "./MessageIdentityIndex";
5
+ export * from "./MessageModel";
6
+ export * from "./SendOperation";
7
+ export * from "./EmailUnsubscribe";
8
+ export * from "./EmailQueue";
@@ -17,3 +17,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./Message"), exports);
18
18
  __exportStar(require("./MediaFile"), exports);
19
19
  __exportStar(require("./Template"), exports);
20
+ __exportStar(require("./MessageIdentityIndex"), exports);
21
+ __exportStar(require("./MessageModel"), exports);
22
+ __exportStar(require("./SendOperation"), exports);
23
+ __exportStar(require("./EmailUnsubscribe"), exports);
24
+ __exportStar(require("./EmailQueue"), exports);
@@ -30,6 +30,10 @@ export declare class UserConfig_Tickets {
30
30
  newContactMessage: NotificationEventPreferences;
31
31
  firstResponseTimeOut: NotificationEventPreferences;
32
32
  resolutionTimeOut: NotificationEventPreferences;
33
+ /** A ticket task was assigned to the user. Optional: configs saved before it existed lack it (off). */
34
+ newTaskAssigned?: NotificationEventPreferences | null;
35
+ /** A task assigned to the user is about to be due. Optional: configs saved before it existed lack it (off). */
36
+ taskDueSoon?: NotificationEventPreferences | null;
33
37
  }
34
38
  export declare class NotificationEventPreferences {
35
39
  email?: boolean | null;
@@ -65,4 +69,6 @@ export declare const notificationEventOptions: {
65
69
  readonly 'tickets.newContactMessage': readonly ["email", "push"];
66
70
  readonly 'tickets.firstResponseTimeOut': readonly ["email", "push"];
67
71
  readonly 'tickets.resolutionTimeOut': readonly ["email", "push"];
72
+ readonly 'tickets.newTaskAssigned': readonly ["email", "push"];
73
+ readonly 'tickets.taskDueSoon': readonly ["email", "push"];
68
74
  };
@@ -38,4 +38,6 @@ exports.notificationEventOptions = {
38
38
  'tickets.newContactMessage': delivery,
39
39
  'tickets.firstResponseTimeOut': delivery,
40
40
  'tickets.resolutionTimeOut': delivery,
41
+ 'tickets.newTaskAssigned': delivery,
42
+ 'tickets.taskDueSoon': delivery,
41
43
  };
@@ -0,0 +1,22 @@
1
+ /** Motivo de una variable sin resolver (VA2). */
2
+ export type UnresolvedVariableReason =
3
+ /** No hay entidad de ese tipo. */
4
+ 'no_entity'
5
+ /** Varias entidades compatibles y ninguna explícita; nunca se elige la primera. */
6
+ | 'ambiguous'
7
+ /** Variable desconocida dentro de un prefijo conocido. */
8
+ | 'unknown_variable';
9
+ export interface UnresolvedVariable {
10
+ /** Texto de la variable, p. ej. "{{contact.name}}". */
11
+ variable: string;
12
+ reason: UnresolvedVariableReason;
13
+ /** Solo ambiguous: ids de las candidatas. */
14
+ candidateIds?: string[];
15
+ }
16
+ /** Resultado del reemplazo (ReplaceVars.ReplaceResult en C#). */
17
+ export interface VariableReplaceResult {
18
+ text: string;
19
+ items: string[];
20
+ /** Sin repetir. */
21
+ unresolved: UnresolvedVariable[];
22
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /*
3
+ * Resultado del reemplazo de variables {{contact.*}}, {{business.*}}, {{agent.*}} y {{conversation.*}} (plan §15.26).
4
+ * La entidad es explícita o la única compatible del contexto (VA1); si no, la variable queda literal en el texto y se
5
+ * informa en unresolved (VA2). El texto se envía tal cual (VA3).
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -4,3 +4,4 @@ export * as Messages from './Messages/index';
4
4
  export * as Notifications from './Notifications/index';
5
5
  export * as Schedules from './Schedules/index';
6
6
  export * as QueueEvent from './EventsQueue/index';
7
+ export * as Variables from './Variables';
@@ -33,10 +33,11 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.QueueEvent = exports.Schedules = exports.Notifications = exports.Messages = exports.Channels = exports.API = void 0;
36
+ exports.Variables = exports.QueueEvent = exports.Schedules = exports.Notifications = exports.Messages = exports.Channels = exports.API = void 0;
37
37
  exports.API = __importStar(require("./API/index"));
38
38
  exports.Channels = __importStar(require("./Channels/index"));
39
39
  exports.Messages = __importStar(require("./Messages/index"));
40
40
  exports.Notifications = __importStar(require("./Notifications/index"));
41
41
  exports.Schedules = __importStar(require("./Schedules/index"));
42
42
  exports.QueueEvent = __importStar(require("./EventsQueue/index"));
43
+ exports.Variables = __importStar(require("./Variables"));
@@ -0,0 +1,53 @@
1
+ /** Colecciones del modelo de empresas (plan §15.15). Base Contacts, shard spaceId hashed. */
2
+ export declare const BUSINESS_COLLECTIONS: {
3
+ readonly Businesses: "Businesses";
4
+ readonly BusinessRoles: "BusinessRoles";
5
+ };
6
+ /** Tipo de dueño de vínculos, notas, asociaciones y eventos (B3). */
7
+ export type CrmEntityType = 'contact' | 'business';
8
+ /** Período de una persona en una empresa (IContact.businessLinks, B4–B7, B12, B15–B17). */
9
+ export interface IContactBusinessLink {
10
+ /** Id estable del período (B15). */
11
+ linkId: string;
12
+ businessId: string;
13
+ /** Ids de IBusinessRole del espacio. */
14
+ roles: string[];
15
+ /** A lo sumo un vínculo activo principal por persona; puede no haber ninguno (B12). */
16
+ isPrimary: boolean;
17
+ /** Inicio; en vínculos migrados = createdAt del contacto (B17). */
18
+ since: Date;
19
+ /** Fin del período; null/ausente = activo. */
20
+ until?: Date | null;
21
+ createdBy: string;
22
+ }
23
+ /** Rol del catálogo del espacio (colección BusinessRoles, B11). Baja lógica con deletedAt. */
24
+ export interface IBusinessRole {
25
+ id?: string;
26
+ spaceId: string;
27
+ name: string;
28
+ isDefault: boolean;
29
+ sortOrder: number;
30
+ deletedAt?: Date | null;
31
+ /** Permisos de portal B2B del rol (§15.16.1 P6). Vacío = solo lo propio. */
32
+ portalPermissions: BusinessPortalPermission[];
33
+ }
34
+ /** Catálogo fijo de permisos de portal B2B (P6). */
35
+ export type BusinessPortalPermission = 'company_tickets_view' | 'company_tickets_create' | 'company_invoices_view' | 'company_subscriptions_manage' | 'company_users_manage';
36
+ /** Roles con los que se siembra BusinessRoles al migrar el espacio (B11). */
37
+ export declare const BUSINESS_ROLE_DEFAULTS: readonly ["Decisor", "Contacto técnico", "Facturación", "Empleado"];
38
+ export type BusinessLinkEventType = 'business_link.added' | 'business_link.updated' | 'business_link.ended';
39
+ /** Payload de business_link.* (B14), publicado en el Outbox de la base Contacts (EV4). aggregateVersion = IContact.revision. */
40
+ export interface IBusinessLinkEventPayload {
41
+ contactId: string;
42
+ linkId: string;
43
+ businessId: string;
44
+ roles: string[];
45
+ isPrimary: boolean;
46
+ since: Date;
47
+ until?: Date | null;
48
+ actor: string;
49
+ occurredAt: Date;
50
+ /** Operación que originó el cambio (correlación). */
51
+ operationId?: string | null;
52
+ aggregateVersion: number;
53
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BUSINESS_ROLE_DEFAULTS = exports.BUSINESS_COLLECTIONS = void 0;
4
+ /** Colecciones del modelo de empresas (plan §15.15). Base Contacts, shard spaceId hashed. */
5
+ exports.BUSINESS_COLLECTIONS = {
6
+ Businesses: 'Businesses',
7
+ BusinessRoles: 'BusinessRoles',
8
+ };
9
+ /** Roles con los que se siembra BusinessRoles al migrar el espacio (B11). */
10
+ exports.BUSINESS_ROLE_DEFAULTS = ['Decisor', 'Contacto técnico', 'Facturación', 'Empleado'];
@@ -0,0 +1,116 @@
1
+ import { Common } from "../index";
2
+ import type { IChannelIdentity } from "./contacts";
3
+ /** Nombres de colecciones del modelo ChannelIdentities (plan §15.14 y §15.14.2). */
4
+ export declare const CHANNEL_IDENTITY_COLLECTIONS: {
5
+ /** Base Contacts, shard spaceId hashed. Solo espacios con channelIdentityModelVersion 2. */
6
+ readonly ChannelIdentities: "ChannelIdentities";
7
+ /** Legacy. Se elimina en E7. */
8
+ readonly ContactAddresses: "ContactAddresses";
9
+ readonly IdentityOperations: "IdentityOperations";
10
+ /** Outbox único de la base Contacts (§15.20 EV4). */
11
+ readonly Outbox: "Outbox";
12
+ /** Base Messages. */
13
+ readonly MessageIdentityIndex: "MessageIdentityIndex";
14
+ };
15
+ /** active: normal · invalid: solo historial (clave self) · merging: fusión en curso · merged: absorbida (clave merged). */
16
+ export type ChannelIdentityStatus = 'active' | 'invalid' | 'merging' | 'merged';
17
+ /** Namespaces de clave. Cada uno pertenece a un solo tipo de identidad. self/merged son técnicos y reservados al servidor. */
18
+ export declare const CHANNEL_IDENTITY_NAMESPACES: {
19
+ readonly Email: "email";
20
+ /** Identidad PHONE: llamadas y SMS. */
21
+ readonly Msisdn: "msisdn";
22
+ readonly WhatsAppPhone: "wa_phone";
23
+ /** Alias con scope = portfolio. Sin portfolio conocido no se genera. */
24
+ readonly WhatsAppBsuid: "wa_bsuid";
25
+ /** Alias sin scope; solo con evidencia. */
26
+ readonly WhatsAppLid: "wa_lid";
27
+ readonly WhatsAppGroup: "wa_group";
28
+ readonly WhatsAppCloudGroup: "wa_cloud_group";
29
+ readonly RcsPhone: "rcs_phone";
30
+ readonly FacebookPsid: "psid";
31
+ readonly InstagramIgsid: "igsid";
32
+ readonly WebChat: "webchat";
33
+ readonly OpenMessaging: "openmessaging";
34
+ readonly MercadoLibreUser: "meli_user";
35
+ readonly Self: "self";
36
+ readonly Merged: "merged";
37
+ };
38
+ export type ChannelIdentityMergeReason = 'variant' | 'admin_merge' | 'rebuilt_email' | 'merge';
39
+ export type ChannelIdentityKeyKind = 'principal' | 'alias' | 'self' | 'merged';
40
+ /** Origen y evidencia de una clave de keys (M7/K2). */
41
+ export interface IChannelIdentityKeyDetail {
42
+ /** Texto idéntico al elemento de keys. */
43
+ key: string;
44
+ kind: ChannelIdentityKeyKind;
45
+ /** webhook-whatsapp, apiQR-extension, migration, manual, resolver… (lista abierta). */
46
+ source: string;
47
+ evidence?: string | null;
48
+ normalizationVersion: number;
49
+ observedAt: Date;
50
+ }
51
+ export type ChannelIdentityLinkStateValue = 'free' | 'reserved' | 'owned' | 'conflict';
52
+ /** Estado interno D15 (K3). No editable por clientes ni expuesto en DTO público. */
53
+ export interface IChannelIdentityLinkState {
54
+ state: ChannelIdentityLinkStateValue;
55
+ /** Personas activas vinculadas (empresas no cuentan). */
56
+ ownerIds: string[];
57
+ operationId?: string | null;
58
+ revision: number;
59
+ updatedAt: Date;
60
+ }
61
+ /**
62
+ * Vínculo confirmado identidad↔persona/empresa (IContact.identities / IBusiness.identities, K6).
63
+ * identityNamespace/displayValue/identityStatus son copia de lectura; la autoridad es ChannelIdentities.
64
+ */
65
+ export interface IContactIdentityLink {
66
+ channelIdentityId: string;
67
+ channelType: Common.Channels.ChannelType;
68
+ label?: string | null;
69
+ note?: string | null;
70
+ isFavorite: boolean;
71
+ sortOrder: number;
72
+ /** Habilita el login al portal con este identificador (§15.16 P1). Teléfono: en la PHONE (P2). */
73
+ portalLoginEnabled: boolean;
74
+ linkedAt: Date;
75
+ linkedBy?: string | null;
76
+ /** Copia de lectura de la clave principal (namespace|scope|valor, §15.24 SN1/SN2). Null hasta migrar/refrescar. */
77
+ key?: string | null;
78
+ identityNamespace?: string | null;
79
+ displayValue?: string | null;
80
+ identityStatus?: ChannelIdentityStatus | null;
81
+ }
82
+ export type IdentityOperationType = 'resolve' | 'merge' | 'attach' | 'detach' | 'move' | 'repair_alias';
83
+ export type IdentityOperationStatus = 'pending' | 'committed' | 'reconciling' | 'completed' | 'failed';
84
+ /** Registro durable de una operación sobre identidades (colección IdentityOperations, K4). */
85
+ export interface IIdentityOperation {
86
+ operationId: string;
87
+ spaceId: string;
88
+ type: IdentityOperationType;
89
+ status: IdentityOperationStatus;
90
+ sourceIds: string[];
91
+ targetId?: string | null;
92
+ pendingSteps: string[];
93
+ actor: string;
94
+ createdAt: Date;
95
+ updatedAt: Date;
96
+ completedAt?: Date | null;
97
+ attempts: number;
98
+ lastError?: string | null;
99
+ }
100
+ /** Escapa un componente de clave: "%" → "%25" y "|" → "%7C" (C03). */
101
+ export declare function escapeChannelIdentityKeyComponent(value: string | null | undefined): string;
102
+ /**
103
+ * Clave canónica "namespace|scope|valor" (M2/C03). Scope null o vacío se escribe vacío.
104
+ * El valor ya debe venir normalizado por el normalizador de su namespace.
105
+ * keyHash (SHA-256 truncado a 16 bytes) se calcula en el backend; ver ChannelIdentityKeyFormat en trii-LibDef.
106
+ */
107
+ export declare function buildChannelIdentityKey(identityNamespace: string, scope: string | null | undefined, normalizedValue: string): string;
108
+ /** Origen de la identidad (M01). Se fija solo al insertar. */
109
+ export type ChannelIdentityCreationSource = 'inbound' | 'manual' | 'import' | 'form' | 'api' | 'migration' | 'merge' | 'portal';
110
+ /**
111
+ * Documento persistido de ChannelIdentities, solo para backends que leen la colección directamente.
112
+ * Incluye el estado interno D15 (linkState), que NUNCA forma parte de IChannelIdentity ni de DTOs/JSON públicos (F01).
113
+ */
114
+ export interface IChannelIdentityDocument extends IChannelIdentity {
115
+ linkState?: IChannelIdentityLinkState | null;
116
+ }
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CHANNEL_IDENTITY_NAMESPACES = exports.CHANNEL_IDENTITY_COLLECTIONS = void 0;
4
+ exports.escapeChannelIdentityKeyComponent = escapeChannelIdentityKeyComponent;
5
+ exports.buildChannelIdentityKey = buildChannelIdentityKey;
6
+ /** Nombres de colecciones del modelo ChannelIdentities (plan §15.14 y §15.14.2). */
7
+ exports.CHANNEL_IDENTITY_COLLECTIONS = {
8
+ /** Base Contacts, shard spaceId hashed. Solo espacios con channelIdentityModelVersion 2. */
9
+ ChannelIdentities: 'ChannelIdentities',
10
+ /** Legacy. Se elimina en E7. */
11
+ ContactAddresses: 'ContactAddresses',
12
+ IdentityOperations: 'IdentityOperations',
13
+ /** Outbox único de la base Contacts (§15.20 EV4). */
14
+ Outbox: 'Outbox',
15
+ /** Base Messages. */
16
+ MessageIdentityIndex: 'MessageIdentityIndex',
17
+ };
18
+ /** Namespaces de clave. Cada uno pertenece a un solo tipo de identidad. self/merged son técnicos y reservados al servidor. */
19
+ exports.CHANNEL_IDENTITY_NAMESPACES = {
20
+ Email: 'email',
21
+ /** Identidad PHONE: llamadas y SMS. */
22
+ Msisdn: 'msisdn',
23
+ WhatsAppPhone: 'wa_phone',
24
+ /** Alias con scope = portfolio. Sin portfolio conocido no se genera. */
25
+ WhatsAppBsuid: 'wa_bsuid',
26
+ /** Alias sin scope; solo con evidencia. */
27
+ WhatsAppLid: 'wa_lid',
28
+ WhatsAppGroup: 'wa_group',
29
+ WhatsAppCloudGroup: 'wa_cloud_group',
30
+ RcsPhone: 'rcs_phone',
31
+ FacebookPsid: 'psid',
32
+ InstagramIgsid: 'igsid',
33
+ WebChat: 'webchat',
34
+ OpenMessaging: 'openmessaging',
35
+ MercadoLibreUser: 'meli_user',
36
+ Self: 'self',
37
+ Merged: 'merged',
38
+ };
39
+ /** Escapa un componente de clave: "%" → "%25" y "|" → "%7C" (C03). */
40
+ function escapeChannelIdentityKeyComponent(value) {
41
+ return value ? value.replace(/%/g, '%25').replace(/\|/g, '%7C') : '';
42
+ }
43
+ /**
44
+ * Clave canónica "namespace|scope|valor" (M2/C03). Scope null o vacío se escribe vacío.
45
+ * El valor ya debe venir normalizado por el normalizador de su namespace.
46
+ * keyHash (SHA-256 truncado a 16 bytes) se calcula en el backend; ver ChannelIdentityKeyFormat en trii-LibDef.
47
+ */
48
+ function buildChannelIdentityKey(identityNamespace, scope, normalizedValue) {
49
+ if (!identityNamespace)
50
+ throw new Error('namespace vacío');
51
+ if (!normalizedValue)
52
+ throw new Error('valor vacío');
53
+ return [identityNamespace, scope, normalizedValue].map(escapeChannelIdentityKeyComponent).join('|');
54
+ }