@trii/types 2.10.823 → 2.11.0

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.
@@ -49,6 +49,7 @@ interface IChannelInfo {
49
49
  interface ChannelConversationRoutingConfig {
50
50
  /** Stable id of a ConversationQueue in the same space as the channel. */
51
51
  defaultQueueId: string;
52
+ defaultOwnerUserId?: string | null;
52
53
  }
53
54
  interface IChannel {
54
55
  id?: string | null;
@@ -1,5 +1,5 @@
1
1
  import { IEventType } from "../../Calendar/Event";
2
- import { IContactAddress } from "../../Contacts/contacts";
2
+ import { IChannelIdentity } from "../../Contacts/contacts";
3
3
  import { UserInfo } from "../../Users/UserTrii";
4
4
  import { IChannelInfo } from "../Channels/Channel";
5
5
  export interface CommentData {
@@ -189,11 +189,11 @@ export interface MessageEmail {
189
189
  /**Remitente del correo */
190
190
  from: string;
191
191
  /**Lista de destinatarios (puede ser uno o varios) */
192
- to: IContactAddress[];
192
+ to: IChannelIdentity[];
193
193
  /**Lista de destinatarios en copia (opcional) */
194
- cc?: IContactAddress[];
194
+ cc?: IChannelIdentity[];
195
195
  /**Lista de destinatarios en copia oculta (opcional) */
196
- bcc?: IContactAddress[];
196
+ bcc?: IChannelIdentity[];
197
197
  /**Asunto del correo */
198
198
  subject: string;
199
199
  preHeader: string;
@@ -210,9 +210,19 @@ export interface MessageEmail {
210
210
  isSpam?: boolean;
211
211
  /**Puntuación de spam (opcional) */
212
212
  spamScore?: number;
213
+ /** Correo importado en la sincronización inicial de la casilla. */
214
+ isInitialSync?: boolean;
215
+ /** Id inmutable del proveedor (Gmail id, Graph id, "{uidValidity}:{uid}" IMAP). No es Message-ID. */
216
+ providerMessageId?: string | null;
217
+ /** Legado: copias por destinatario del envío actual. No usar para hilos. */
218
+ relatedMessages?: MessageEmailRelated[];
213
219
  bodyJson?: string;
214
220
  projectData?: string;
215
221
  }
222
+ export interface MessageEmailRelated {
223
+ messageId: string;
224
+ shardKey: string;
225
+ }
216
226
  export interface EmailDocument {
217
227
  id: string;
218
228
  /**The name for the file*/
@@ -554,6 +564,12 @@ export interface IMessage {
554
564
  */
555
565
  references?: MessageRelatedResource[];
556
566
  messageReference?: MessageReference;
567
+ /**
568
+ * Identidad del mensaje dentro de su hilo y evidencia para resolver la conversación.
569
+ * Común a todos los canales. Ausente en mensajes anteriores al contrato.
570
+ * La autoridad sigue siendo conversationId; no reemplaza a references.
571
+ */
572
+ thread?: MessageThread | null;
557
573
  /**
558
574
  * Selección realizada por el usuario, como un botón o una opción de lista.
559
575
  * Conserva el valor devuelto por el proveedor y el texto visible.
@@ -571,6 +587,34 @@ export interface IMessage {
571
587
  updatedAt?: Date;
572
588
  updatedBy?: UserInfo;
573
589
  }
590
+ export type MessageThreadResolutionMethod = "provided" | "in_reply_to" | "references" | "external_thread" | "channel_rule" | "new_conversation" | "conflict";
591
+ /**
592
+ * Identidad de un mensaje dentro de su hilo (Conversation).
593
+ * Email: key = Message-ID, inReplyTo = In-Reply-To, references = References.
594
+ * WhatsApp: key = wamid, inReplyTo = context.id.
595
+ */
596
+ export interface MessageThread {
597
+ /** Clave con la que otros mensajes del mismo canal referencian a este. Única dentro de spaceId + canal. */
598
+ key?: string | null;
599
+ /** false: clave generada por Trii no confirmada por el proveedor. */
600
+ keyConfirmed?: boolean | null;
601
+ /** Claves del mensaje respondido. */
602
+ inReplyTo: string[];
603
+ /** Cadena de claves del hilo, más antigua primero. */
604
+ references: string[];
605
+ /** Id del hilo en el proveedor, en el namespace del canal. */
606
+ externalThreadId?: string | null;
607
+ /** Lo escribe message-processor al resolver conversationId. */
608
+ resolution?: MessageThreadResolution | null;
609
+ }
610
+ export interface MessageThreadResolution {
611
+ method: MessageThreadResolutionMethod | (string & {});
612
+ matchedKey?: string | null;
613
+ /** Solo con method = conflict. */
614
+ conflictingConversationIds?: string[] | null;
615
+ reopened: boolean;
616
+ resolvedAt: Date;
617
+ }
574
618
  export interface MessageInteraction {
575
619
  type: "button_reply" | "list_reply";
576
620
  value: string;
@@ -4,7 +4,7 @@ export interface IContactInfo {
4
4
  name: string;
5
5
  imageUrl?: string;
6
6
  isBusiness: boolean | false;
7
- contactAddresses: IContactAddress[];
7
+ contactAddresses: IChannelIdentity[];
8
8
  businessName?: string;
9
9
  businessId?: string;
10
10
  }
@@ -17,15 +17,15 @@ export interface IBusiness {
17
17
  ownerUserId?: string;
18
18
  membersId: string[];
19
19
  members: IContactInfo[];
20
- phones: IContactAddress[];
21
- emails: IContactAddress[];
22
- ims_instagram: IContactAddress[];
23
- ims_facebook: IContactAddress[];
24
- ims_webchat: IContactAddress[];
25
- ims_whatsapp: IContactAddress[];
26
- ims_mercadolibre: IContactAddress[];
27
- ims_rcs: IContactAddress[];
28
- ims_openmessaging: IContactAddress[];
20
+ phones: IChannelIdentity[];
21
+ emails: IChannelIdentity[];
22
+ ims_instagram: IChannelIdentity[];
23
+ ims_facebook: IChannelIdentity[];
24
+ ims_webchat: IChannelIdentity[];
25
+ ims_whatsapp: IChannelIdentity[];
26
+ ims_mercadolibre: IChannelIdentity[];
27
+ ims_rcs: IChannelIdentity[];
28
+ ims_openmessaging: IChannelIdentity[];
29
29
  address1: IContactPostalAddress;
30
30
  address2: IContactPostalAddress;
31
31
  tags: IContactTag[];
@@ -58,17 +58,17 @@ export interface IContact {
58
58
  ownerUserId?: string;
59
59
  businessId?: string;
60
60
  businessName?: string;
61
- phones: IContactAddress[];
62
- emails: IContactAddress[];
61
+ phones: IChannelIdentity[];
62
+ emails: IChannelIdentity[];
63
63
  /** Email the contact uses to log in to the customer portal. */
64
64
  customerPortalLogin?: string;
65
- ims_instagram: IContactAddress[];
66
- ims_facebook: IContactAddress[];
67
- ims_webchat: IContactAddress[];
68
- ims_whatsapp: IContactAddress[];
69
- ims_mercadolibre: IContactAddress[];
70
- ims_rcs: IContactAddress[];
71
- ims_openmessaging: IContactAddress[];
65
+ ims_instagram: IChannelIdentity[];
66
+ ims_facebook: IChannelIdentity[];
67
+ ims_webchat: IChannelIdentity[];
68
+ ims_whatsapp: IChannelIdentity[];
69
+ ims_mercadolibre: IChannelIdentity[];
70
+ ims_rcs: IChannelIdentity[];
71
+ ims_openmessaging: IChannelIdentity[];
72
72
  address1: IContactPostalAddress;
73
73
  address2: IContactPostalAddress;
74
74
  tags: IContactTag[];
@@ -168,7 +168,14 @@ export declare enum ContactField_type {
168
168
  LIST_SINGLE = 31,
169
169
  LIST_OBJECT = 32
170
170
  }
171
- export interface IContactAddress {
171
+ /**
172
+ * ChannelIdentity = identidad externa en un canal (email, teléfono, PSID de FB, IGSID, bsuid de WhatsApp…).
173
+ * Existe sin contacto y puede estar vinculada a 0..N contactos.
174
+ * Antes IContactAddress: se renombró solo el tipo; la colección Mongo ("ContactAddresses") y los nombres de
175
+ * propiedades que la referencian (contactAddresses, contactAddress, contactAddressId, emails, phones, ims_*)
176
+ * no cambian.
177
+ */
178
+ export interface IChannelIdentity {
172
179
  id: string;
173
180
  channelType: Common.Channels.ChannelType;
174
181
  /**
@@ -6,7 +6,7 @@ import type { ConversationSlaSnapshot, ConversationSlaStatus } from './Conversat
6
6
  import { ILabel } from "./Label";
7
7
  import { GroupInfo } from "./Groups/Group";
8
8
  import { Channels } from "../Common/index";
9
- import { IContactAddress, IContactInfo } from "../Contacts/contacts";
9
+ import { IChannelIdentity, IContactInfo } from "../Contacts/contacts";
10
10
  import { IEnding } from "./Ending";
11
11
  import { ChatType } from "../Chats/Chat";
12
12
  import { TransferConversationCommand, TransferConversationResult } from "./Transfer";
@@ -43,6 +43,25 @@ export interface IConversation {
43
43
  externalThreadId?: string | null;
44
44
  /** OpenMessaging: datos del hilo que mantiene channel-openmessaging. Null en los demás canales. */
45
45
  openMessaging?: IConversationOpenMessaging | null;
46
+ /**
47
+ * Referencias del hilo del proveedor para resolver próximos mensajes del mismo canal.
48
+ * Dato interno de resolución: las APIs de lectura del frontend no lo exponen.
49
+ */
50
+ externalThread?: ConversationExternalThread | null;
51
+ /**
52
+ * Direcciones externas del hilo (remitente, Para y CC externos; nunca CCO).
53
+ * Ausente o vacía en conversaciones anteriores: usar remoteAddress/contactInfo.
54
+ */
55
+ addresses?: ConversationAddress[];
56
+ /** true si se dejaron de agregar direcciones por superar CONVERSATION_MAX_ADDRESSES. */
57
+ addressesTruncated?: boolean;
58
+ /**
59
+ * Contactos asociados (0..N). Independientes de addresses.
60
+ * contactInfo es la proyección legada: solo con exactamente un contacto.
61
+ */
62
+ contacts?: ConversationContact[];
63
+ /** Contactos descartados por un agente; no se vuelven a sugerir ni asociar. Solo en el detalle. */
64
+ dismissedContactIds?: string[];
46
65
  channelInfo: Channels.IChannelInfo;
47
66
  status: ConversationStatus;
48
67
  priority: 'low' | 'normal' | 'high' | 'urgent';
@@ -116,6 +135,52 @@ export interface IConversation {
116
135
  lastCommentId?: string | null;
117
136
  }
118
137
  export type InteractionKind = 'private' | 'wall_post' | 'comment' | 'mention';
138
+ /** Límite de direcciones por conversación. */
139
+ export declare const CONVERSATION_MAX_ADDRESSES = 50;
140
+ /** Límite de contactos por conversación. */
141
+ export declare const CONVERSATION_MAX_CONTACTS = 50;
142
+ export type ConversationContactOrigin = 'auto_match' | 'manual' | 'migration';
143
+ /** Dirección externa que participa del hilo. Snapshot de IChannelIdentity. */
144
+ export interface ConversationAddress {
145
+ /** IChannelIdentity.id (colección "ContactAddresses"). */
146
+ channelIdentityId: string;
147
+ channelType: Channels.ChannelType;
148
+ /** Normalizada; clave de búsqueda. Email: completa en minúsculas. */
149
+ address: string;
150
+ /** Texto recibido, para mostrar. */
151
+ originalAddress?: string | null;
152
+ displayName?: string | null;
153
+ /** Cuándo la dirección entró a esta conversación. Se escribe una vez; la actividad vive en IChannelIdentity. */
154
+ addedAt: Date;
155
+ }
156
+ /** Contacto del CRM asociado a la conversación. */
157
+ export interface ConversationContact {
158
+ contactId: string;
159
+ name?: string | null;
160
+ imageUrl?: string | null;
161
+ origin: ConversationContactOrigin | (string & {});
162
+ /** Direcciones por las que se asoció; vacía en asociación manual sin coincidencia. */
163
+ viaChannelIdentityIds: string[];
164
+ associatedAt: Date;
165
+ /** userId del agente; null para auto_match y migración. */
166
+ associatedBy?: string | null;
167
+ }
168
+ /** Límite de claves en ConversationExternalThread.keys. */
169
+ export declare const CONVERSATION_EXTERNAL_THREAD_MAX_KEYS = 200;
170
+ /**
171
+ * Referencias del hilo del proveedor guardadas en la conversación.
172
+ * Búsqueda siempre dentro de spaceId + channelInfo.id.
173
+ */
174
+ export interface ConversationExternalThread {
175
+ /** Id del hilo en el proveedor. Generaliza externalThreadId. */
176
+ threadId?: string | null;
177
+ /** Primera clave conocida del hilo. Nunca se descarta. */
178
+ rootKey?: string | null;
179
+ /** Claves de mensajes (Message.thread.key), más recientes al final. Solo canales con hilo real (email). */
180
+ keys: string[];
181
+ keysTruncated: boolean;
182
+ updatedAt: Date;
183
+ }
119
184
  /** Hilo de OpenMessaging. Lo escribe channel-openmessaging al crear la conversación. */
120
185
  export interface IConversationOpenMessaging {
121
186
  /** Usuario de la app dueño del hilo; no cambia. Es el contacto de la conversación. */
@@ -132,7 +197,7 @@ export interface IWhatsAppGroupInfo {
132
197
  description: string;
133
198
  }
134
199
  export interface IWhatsAppGroupMember {
135
- contactAddress: IContactAddress;
200
+ contactAddress: IChannelIdentity;
136
201
  contactId: string;
137
202
  name: string;
138
203
  contactInfo: IContactInfo;
@@ -333,6 +398,7 @@ export type ConversationAssignmentSnapshot = {
333
398
  acceptedAt?: never;
334
399
  } | QueuedConversationAssignmentBase & {
335
400
  status: 'queued' | 'routing';
401
+ initialChannelOwnerUserId?: ID;
336
402
  owner: NoConversationOwner;
337
403
  offeredAt?: never;
338
404
  offerExpiresAt?: never;
@@ -1,6 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ConversationStatus = exports.AssignMethod = exports.ConversationDirection = exports.ConversationBotStatus = void 0;
3
+ exports.ConversationStatus = exports.AssignMethod = exports.ConversationDirection = exports.ConversationBotStatus = exports.CONVERSATION_EXTERNAL_THREAD_MAX_KEYS = exports.CONVERSATION_MAX_CONTACTS = exports.CONVERSATION_MAX_ADDRESSES = void 0;
4
+ // export enum ConversationContextType {
5
+ // TICKET = 'TICKET',
6
+ // CONVERSATION = 'CONVERSATION',
7
+ // LEAD = 'LEAD',
8
+ // DEBT = 'DEBT',
9
+ // }
10
+ // export interface IConversationContextReference {
11
+ // entityType: ConversationContextType;
12
+ // entityId: string;
13
+ // role?: string;
14
+ // linkedAt: Date;
15
+ // linkedBy?: string;
16
+ // }
17
+ /** Límite de direcciones por conversación. */
18
+ exports.CONVERSATION_MAX_ADDRESSES = 50;
19
+ /** Límite de contactos por conversación. */
20
+ exports.CONVERSATION_MAX_CONTACTS = 50;
21
+ /** Límite de claves en ConversationExternalThread.keys. */
22
+ exports.CONVERSATION_EXTERNAL_THREAD_MAX_KEYS = 200;
4
23
  /** @deprecated Estado legacy. Usar ConversationAutomationStatus para ejecuciones nuevas. */
5
24
  var ConversationBotStatus;
6
25
  (function (ConversationBotStatus) {
@@ -102,7 +102,7 @@ export interface RouteConversationCommand {
102
102
  party: RoutingPartyContext;
103
103
  requestedAt: Date;
104
104
  }
105
- export type RoutingSelectionSource = 'party_owner' | 'strategy' | 'fallback';
105
+ export type RoutingSelectionSource = 'channel_owner' | 'party_owner' | 'strategy' | 'fallback';
106
106
  export type PartyOwnerResolutionFailure = 'party_not_found' | 'party_without_owner' | 'owner_user_not_found' | 'not_authorized' | 'not_participating' | 'unavailable' | 'channel_ineligible' | 'capacity_exhausted';
107
107
  type FailedPartyOwnerEvaluation = {
108
108
  party: Extract<RoutingPartyContext, {
@@ -41,7 +41,7 @@ export interface ISubscriberSubscription {
41
41
  }
42
42
  export interface ISubscriberContactLink {
43
43
  contactId: string;
44
- /** IContactAddress.id de la dirección. */
44
+ /** IChannelIdentity.id de la dirección. */
45
45
  contactAddressId: string;
46
46
  linkedAt: CampaignTimestamp;
47
47
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trii/types",
3
- "version": "2.10.823",
3
+ "version": "2.11.0",
4
4
  "description": "Types definitions for Trii projects - ",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",