@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,42 @@
1
+ import type { IdentityOperationStatus, IdentityOperationType } from './ChannelIdentityModel';
2
+ /**
3
+ * Códigos de error de identidades y vínculos (plan §15.25 ER2). Pending no es un error: es 202 con
4
+ * IdentityOperationAccepted.
5
+ */
6
+ export type IdentityErrorCode =
7
+ /** 409, no reintentable: la identidad ya tiene un contacto activo y el espacio es exclusivo (D15). */
8
+ 'identity_linked_to_other_contact'
9
+ /** 409, no reintentable: conflicto heredado (linkState = conflict); lo resuelve un admin. */
10
+ | 'identity_in_conflict'
11
+ /** 503, reintentable: espacio en ventana de mantenimiento; sin duración prometida. */
12
+ | 'space_in_maintenance'
13
+ /** 409, reintentable: otra operación tiene tomada la identidad. */
14
+ | 'identity_operation_in_progress';
15
+ /** Estado HTTP y si se puede reintentar, por código (ER2). */
16
+ export declare const IDENTITY_ERROR_HTTP: Readonly<Record<IdentityErrorCode, {
17
+ status: number;
18
+ retryable: boolean;
19
+ }>>;
20
+ /** Error de identidades y vínculos (ER1): ProblemDetails (RFC 7807, application/problem+json) con campos extra. */
21
+ export interface IdentityProblem {
22
+ type: string;
23
+ title: string;
24
+ status: number;
25
+ detail?: string | null;
26
+ instance?: string | null;
27
+ code: IdentityErrorCode;
28
+ retryable: boolean;
29
+ channelIdentityId?: string;
30
+ /** Solo identity_linked_to_other_contact y solo con permiso para ver ese contacto. */
31
+ currentOwnerId?: string;
32
+ /** Solo identity_operation_in_progress. */
33
+ operationId?: string;
34
+ /** Solo space_in_maintenance (SpaceMaintenance.reason). */
35
+ maintenanceReason?: string;
36
+ }
37
+ /** Respuesta 202 de una mutación que quedó pending (ER2): nunca éxito prematuro. */
38
+ export interface IdentityOperationAccepted {
39
+ operationId: string;
40
+ type: IdentityOperationType;
41
+ status: IdentityOperationStatus;
42
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IDENTITY_ERROR_HTTP = void 0;
4
+ /** Estado HTTP y si se puede reintentar, por código (ER2). */
5
+ exports.IDENTITY_ERROR_HTTP = {
6
+ identity_linked_to_other_contact: { status: 409, retryable: false },
7
+ identity_in_conflict: { status: 409, retryable: false },
8
+ space_in_maintenance: { status: 503, retryable: true },
9
+ identity_operation_in_progress: { status: 409, retryable: true },
10
+ };
@@ -0,0 +1,60 @@
1
+ import type { CrmEntityType } from './BusinessModel';
2
+ import type { IContactIdentityLink, ChannelIdentityMergeReason } from './ChannelIdentityModel';
3
+ /** Familia identidad↔dueño (CI-D10, §15.20 EV1). Outbox de la base Contacts (EV4). */
4
+ export type IdentityEventType = 'identity_link.added' | 'identity_link.updated' | 'identity_link.removed' | 'identity_link.moved' | 'channel_identity.keys_changed' | 'channel_identity.merged' | 'channel_identity.status_changed';
5
+ /** Dueño tipado de un vínculo. */
6
+ export interface IdentityOwnerRef {
7
+ entityType: CrmEntityType;
8
+ entityId: string;
9
+ }
10
+ /** identity_link.added / updated / removed (aggregate = dueño). */
11
+ export interface IdentityLinkEventPayload {
12
+ owner: IdentityOwnerRef;
13
+ channelIdentityId: string;
14
+ /** Vínculo después del cambio; null en removed. */
15
+ link?: IContactIdentityLink | null;
16
+ /** En updated: campos que cambiaron. */
17
+ changedFields: string[];
18
+ actor: string;
19
+ occurredAt: Date;
20
+ operationId?: string | null;
21
+ aggregateVersion: number;
22
+ }
23
+ /** identity_link.moved (aggregate = identidad). */
24
+ export interface IdentityLinkMovedEventPayload {
25
+ channelIdentityId: string;
26
+ from: IdentityOwnerRef;
27
+ to: IdentityOwnerRef;
28
+ actor: string;
29
+ occurredAt: Date;
30
+ operationId?: string | null;
31
+ aggregateVersion: number;
32
+ }
33
+ export interface ChannelIdentityKeysChangedEventPayload {
34
+ channelIdentityId: string;
35
+ addedKeys: string[];
36
+ removedKeys: string[];
37
+ actor: string;
38
+ occurredAt: Date;
39
+ operationId?: string | null;
40
+ aggregateVersion: number;
41
+ }
42
+ export interface ChannelIdentityMergedEventPayload {
43
+ sourceId: string;
44
+ targetId: string;
45
+ mergeReason: ChannelIdentityMergeReason | (string & {});
46
+ movedKeys: string[];
47
+ actor: string;
48
+ occurredAt: Date;
49
+ operationId?: string | null;
50
+ aggregateVersion: number;
51
+ }
52
+ export interface ChannelIdentityStatusChangedEventPayload {
53
+ channelIdentityId: string;
54
+ fromStatus: string;
55
+ toStatus: string;
56
+ actor: string;
57
+ occurredAt: Date;
58
+ operationId?: string | null;
59
+ aggregateVersion: number;
60
+ }
@@ -0,0 +1,51 @@
1
+ import { Common } from "../index";
2
+ /** Colecciones de la base de trii-admin para el cambio de opción D15 (plan §15.25 ER5). */
3
+ export declare const IDENTITY_POLICY_COLLECTIONS: {
4
+ readonly IdentityPolicyChanges: "IdentityPolicyChanges";
5
+ readonly IdentityPolicyConflicts: "IdentityPolicyConflicts";
6
+ };
7
+ /**
8
+ * Estados de un cambio de opción D15 (ER3). scheduled: cancelable. running: en ventana de mantenimiento.
9
+ * interrupted: falló el recálculo; el espacio sigue en mantenimiento y un admin reanuda desde checkpoint.
10
+ * canceled: solo desde scheduled.
11
+ */
12
+ export type IdentityPolicyChangeStatus = 'scheduled' | 'running' | 'interrupted' | 'completed' | 'canceled';
13
+ export declare function isTerminalIdentityPolicyChangeStatus(status: IdentityPolicyChangeStatus): boolean;
14
+ export interface IdentityPolicyChangeProgress {
15
+ processed: number;
16
+ total: number;
17
+ }
18
+ /**
19
+ * Cambio de allowDuplicateContactChannels en ventana de mantenimiento (N19, ER3). Lo escribe y expone solo
20
+ * trii-admin-api (ER5); Space.maintenance sigue siendo la señal para los writers. Conflictos aparte, paginados (ER4).
21
+ */
22
+ export interface IdentityPolicyChange {
23
+ changeId: string;
24
+ spaceId: string;
25
+ /** Valor destino (false = exclusivo para personas). */
26
+ allowDuplicateContactChannels: boolean;
27
+ status: IdentityPolicyChangeStatus;
28
+ scheduledAt?: Date | null;
29
+ startedAt?: Date | null;
30
+ completedAt?: Date | null;
31
+ /** userId del admin. */
32
+ actor: string;
33
+ progress: IdentityPolicyChangeProgress;
34
+ conflictCount: number;
35
+ /** Solo admins. */
36
+ lastError?: string | null;
37
+ createdAt: Date;
38
+ updatedAt: Date;
39
+ }
40
+ /** Identidad en conflict tras pasar a exclusivo (ER4). GET .../IdentityPolicyChanges/{changeId}/Conflicts, por cursor. */
41
+ export interface IdentityPolicyConflict {
42
+ changeId: string;
43
+ spaceId: string;
44
+ channelIdentityId: string;
45
+ channelType: Common.Channels.ChannelType;
46
+ /** Clave principal (formato común). */
47
+ key: string;
48
+ displayValue?: string | null;
49
+ /** Personas activas vinculadas (2 o más). */
50
+ ownerContactIds: string[];
51
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IDENTITY_POLICY_COLLECTIONS = void 0;
4
+ exports.isTerminalIdentityPolicyChangeStatus = isTerminalIdentityPolicyChangeStatus;
5
+ /** Colecciones de la base de trii-admin para el cambio de opción D15 (plan §15.25 ER5). */
6
+ exports.IDENTITY_POLICY_COLLECTIONS = {
7
+ IdentityPolicyChanges: 'IdentityPolicyChanges',
8
+ IdentityPolicyConflicts: 'IdentityPolicyConflicts',
9
+ };
10
+ function isTerminalIdentityPolicyChangeStatus(status) {
11
+ return status === 'completed' || status === 'canceled';
12
+ }
@@ -1,7 +1,15 @@
1
1
  import { UserInfo } from "../Users/UserTrii";
2
+ import type { CrmEntityType } from "./BusinessModel";
3
+ import type { IMessage } from "../Common/Messages/Message";
4
+ /** Nota de persona o empresa (colección "Notes", §15.19). Las notas de conversación siguen siendo IMessage kind = note. */
2
5
  export interface INote {
3
6
  id: string;
4
7
  spaceId: string;
8
+ /** Tipo de dueño (NT1). Obligatorio en notas nuevas. */
9
+ entityType?: CrmEntityType;
10
+ /** Id del dueño. Obligatorio en notas nuevas. */
11
+ entityId?: string;
12
+ /** Legacy: igual a entityId si el dueño es persona; vacío en notas de empresa. Se retira en E7. */
5
13
  contactId: string;
6
14
  title: string;
7
15
  text: string;
@@ -13,3 +21,19 @@ export interface INote {
13
21
  deletedAt?: Date;
14
22
  deletedBy?: string;
15
23
  }
24
+ export type EntityHistorySourceType = 'message' | 'note';
25
+ /** Elemento del historial combinado de una ficha (NT3, N08), ya deduplicado y autorizado. */
26
+ export interface EntityHistoryItem {
27
+ sourceType: EntityHistorySourceType;
28
+ timestamp: Date;
29
+ /** Id del mensaje o de la nota. */
30
+ id: string;
31
+ message?: IMessage | null;
32
+ note?: INote | null;
33
+ }
34
+ /** Página del historial combinado (hasta 50 elementos lógicos); nextCursor opaco, null si no hay más. */
35
+ export interface EntityHistoryPage {
36
+ items: EntityHistoryItem[];
37
+ nextCursor?: string | null;
38
+ }
39
+ export declare const ENTITY_HISTORY_PAGE_SIZE = 50;
@@ -1,2 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ENTITY_HISTORY_PAGE_SIZE = void 0;
4
+ exports.ENTITY_HISTORY_PAGE_SIZE = 50;
@@ -1,31 +1,32 @@
1
1
  import { Common } from "../index";
2
+ import type { IContactBusinessLink } from "./BusinessModel";
3
+ import type { ChannelIdentityStatus, ChannelIdentityMergeReason, ChannelIdentityCreationSource, IChannelIdentityKeyDetail, IContactIdentityLink } from "./ChannelIdentityModel";
2
4
  export interface IContactInfo {
3
5
  id: string;
4
6
  name: string;
5
7
  imageUrl?: string;
6
8
  isBusiness: boolean | false;
7
- contactAddresses: IChannelIdentity[];
9
+ contactAddresses: IContactAddress[];
8
10
  businessName?: string;
9
11
  businessId?: string;
10
12
  }
13
+ /**
14
+ * Empresa (colección "Businesses", plan §15.15). Canales de contacto solo por identities (B10/B18);
15
+ * la relación con personas vive en IContact.businessLinks (B4).
16
+ */
11
17
  export interface IBusiness {
12
18
  id: string;
13
19
  spaceId: string;
20
+ /** A unique identifier for the contact outside of the system.*/
21
+ externalId?: string;
14
22
  counters?: ICounters;
15
23
  name: string;
16
24
  imageUrl: string;
17
25
  ownerUserId?: string;
18
- membersId: string[];
19
- members: IContactInfo[];
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[];
26
+ /** Vínculos confirmados con ChannelIdentities (K6). Único canal de contacto de la empresa (B10/B18). */
27
+ identities?: IContactIdentityLink[];
28
+ /** Revisión del agregado; aggregateVersion de identity_link.* de la empresa (EV3). */
29
+ revision?: number | null;
29
30
  address1: IContactPostalAddress;
30
31
  address2: IContactPostalAddress;
31
32
  tags: IContactTag[];
@@ -49,6 +50,8 @@ export interface ICounters {
49
50
  export interface IContact {
50
51
  id: string;
51
52
  spaceId: string;
53
+ /** A unique identifier for the contact outside of the system.*/
54
+ externalId?: string;
52
55
  counters?: ICounters;
53
56
  name: string;
54
57
  firstName: string;
@@ -58,17 +61,23 @@ export interface IContact {
58
61
  ownerUserId?: string;
59
62
  businessId?: string;
60
63
  businessName?: string;
61
- phones: IChannelIdentity[];
62
- emails: IChannelIdentity[];
63
- /** Email the contact uses to log in to the customer portal. */
64
+ phones: IContactAddress[];
65
+ emails: IContactAddress[];
66
+ /** @deprecated Reemplazado por IContactIdentityLink.portalLoginEnabled (§15.16 P1). */
64
67
  customerPortalLogin?: string;
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[];
68
+ ims_instagram: IContactAddress[];
69
+ ims_facebook: IContactAddress[];
70
+ ims_webchat: IContactAddress[];
71
+ ims_whatsapp: IContactAddress[];
72
+ ims_mercadolibre: IContactAddress[];
73
+ ims_rcs: IContactAddress[];
74
+ ims_openmessaging: IContactAddress[];
75
+ /** Vínculos confirmados con ChannelIdentities (channelIdentityModelVersion 2; K6). Ausente en espacios legacy. */
76
+ identities?: IContactIdentityLink[];
77
+ /** Vínculos persona→empresa (B4–B7, B12, B15–B17). Ausente en espacios legacy (siguen con businessId/businessName). */
78
+ businessLinks?: IContactBusinessLink[];
79
+ /** Revisión del agregado para escrituras condicionales y aggregateVersion de eventos (R04). */
80
+ revision?: number | null;
72
81
  address1: IContactPostalAddress;
73
82
  address2: IContactPostalAddress;
74
83
  tags: IContactTag[];
@@ -95,7 +104,9 @@ export declare enum ContactOrigin {
95
104
  IMPORT = 1,
96
105
  CALL = 2,
97
106
  TICKET = 3,
98
- FORM = 4
107
+ FORM = 4,
108
+ /** Alta desde el portal de clientes (§15.16 P4). */
109
+ PORTAL = 5
99
110
  }
100
111
  export interface IContactPostalAddress {
101
112
  street: string;
@@ -169,14 +180,13 @@ export declare enum ContactField_type {
169
180
  LIST_OBJECT = 32
170
181
  }
171
182
  /**
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.
183
+ * @deprecated Forma legacy (colección "ContactAddresses" y copias embebidas: phones/emails/ims_*,
184
+ * IContactInfo.contactAddresses, MessageEmail to/cc/bcc, WhatsAppGroupMember.contactAddress).
185
+ * Vigente en espacios con channelIdentityModelVersion ausente o 1. El modelo nuevo es IChannelIdentity. Se retira en E7.
177
186
  */
178
- export interface IChannelIdentity {
187
+ export interface IContactAddress {
179
188
  id: string;
189
+ spaceId?: string;
180
190
  channelType: Common.Channels.ChannelType;
181
191
  /**
182
192
  * No es un id del canal de Trii.
@@ -195,14 +205,69 @@ export interface IChannelIdentity {
195
205
  note: string;
196
206
  isVerified: boolean;
197
207
  isFavorite: boolean;
208
+ isGroup?: boolean;
209
+ dateLastMsgIn?: Date;
210
+ dateLastMsgOut?: Date;
211
+ channelActivities?: ContactAddressChannelActivity[];
212
+ subscriptionsAllowed: string[];
213
+ subscriptionsRejected: string[];
214
+ complaintEmails?: string[];
215
+ createdAt: Date;
216
+ verifiedAt?: Date | null;
217
+ verifiedBy?: string | null;
218
+ }
219
+ /**
220
+ * ChannelIdentity = identidad externa en un canal (email, teléfono, PSID de FB, IGSID, bsuid de WhatsApp…).
221
+ * Existe sin contacto y puede estar vinculada a 0..N contactos.
222
+ * Documento de la colección "ChannelIdentities" (espacios con channelIdentityModelVersion 2; plan §15.14).
223
+ * Mismo id que en ContactAddresses al migrar. La forma legacy ("ContactAddresses" y sus copias embebidas)
224
+ * es IContactAddress (K7 revisado: dos tipos).
225
+ */
226
+ export interface IChannelIdentity {
227
+ id: string;
228
+ spaceId?: string;
229
+ channelType: Common.Channels.ChannelType;
230
+ /** Ver ChannelIdentityStatus. */
231
+ status?: ChannelIdentityStatus;
232
+ /** Namespace de la clave principal (ver CHANNEL_IDENTITY_NAMESPACES). */
233
+ identityNamespace?: string;
234
+ /** Alcance externo de la clave principal (página, cuenta, portfolio). Ausente = sin scope. */
235
+ scope?: string | null;
236
+ /** Valor normalizado de la clave principal. Las búsquedas por clave usan keys. */
237
+ normalizedValue?: string;
238
+ normalizationVersion?: number;
239
+ displayValue?: string;
240
+ /** Todas las claves "namespace|scope|valor" (buildChannelIdentityKey). Índice único {spaceId, keys}. */
241
+ keys?: string[];
242
+ keyDetails?: IChannelIdentityKeyDetail[];
243
+ /** WHATSAPP/RCS: identidad PHONE del mismo E.164. */
244
+ phoneIdentityId?: string;
245
+ /** status merged: identidad que la absorbió. Canonizar antes de leer claves. */
246
+ mergedIntoId?: string;
247
+ mergeReason?: ChannelIdentityMergeReason;
248
+ mergedAt?: Date;
249
+ /** Origen (M01). Se fija solo al insertar. Distinto de keyDetails.source. */
250
+ creationSource?: ChannelIdentityCreationSource;
251
+ /** userId del actor autenticado, nunca tomado del payload. */
252
+ createdBy?: string;
253
+ updatedAt?: Date;
254
+ /** Revisión del documento; aggregateVersion de channel_identity.* (EV3). */
255
+ revision?: number | null;
256
+ profileName: string;
257
+ profileUrl: string;
258
+ profileUrlDate?: Date;
259
+ telInfo?: IContactTelInfo;
260
+ isVerified: boolean;
261
+ isGroup?: boolean;
198
262
  dateLastMsgIn?: Date;
199
263
  dateLastMsgOut?: Date;
200
264
  channelActivities?: ContactAddressChannelActivity[];
201
265
  subscriptionsAllowed: string[];
202
266
  subscriptionsRejected: string[];
267
+ complaintEmails?: string[];
203
268
  createdAt: Date;
204
- verifiedAt?: Date;
205
- verifiedBy?: string;
269
+ verifiedAt?: Date | null;
270
+ verifiedBy?: string | null;
206
271
  }
207
272
  export interface ContactAddressChannelActivity {
208
273
  externalChannelId: string;
@@ -8,6 +8,8 @@ var ContactOrigin;
8
8
  ContactOrigin[ContactOrigin["CALL"] = 2] = "CALL";
9
9
  ContactOrigin[ContactOrigin["TICKET"] = 3] = "TICKET";
10
10
  ContactOrigin[ContactOrigin["FORM"] = 4] = "FORM";
11
+ /** Alta desde el portal de clientes (§15.16 P4). */
12
+ ContactOrigin[ContactOrigin["PORTAL"] = 5] = "PORTAL";
11
13
  })(ContactOrigin || (exports.ContactOrigin = ContactOrigin = {}));
12
14
  var ContactField_Item_Type;
13
15
  (function (ContactField_Item_Type) {
@@ -9,3 +9,8 @@ export * from './options';
9
9
  export * from './DuplicateContact';
10
10
  export * from './CommunicationEndpoint';
11
11
  export * from './CommunicationMethod';
12
+ export * from './ChannelIdentityModel';
13
+ export * from './BusinessModel';
14
+ export * from './IdentityEvents';
15
+ export * from './IdentityErrors';
16
+ export * from './IdentityPolicyChange';
@@ -25,3 +25,8 @@ __exportStar(require("./options"), exports);
25
25
  __exportStar(require("./DuplicateContact"), exports);
26
26
  __exportStar(require("./CommunicationEndpoint"), exports);
27
27
  __exportStar(require("./CommunicationMethod"), exports);
28
+ __exportStar(require("./ChannelIdentityModel"), exports);
29
+ __exportStar(require("./BusinessModel"), exports);
30
+ __exportStar(require("./IdentityEvents"), exports);
31
+ __exportStar(require("./IdentityErrors"), exports);
32
+ __exportStar(require("./IdentityPolicyChange"), exports);
@@ -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 { IChannelIdentity, IContactInfo } from "../Contacts/contacts";
9
+ import { IContactAddress, IContactInfo } from "../Contacts/contacts";
10
10
  import { IEnding } from "./Ending";
11
11
  import { ChatType } from "../Chats/Chat";
12
12
  import { TransferConversationCommand, TransferConversationResult } from "./Transfer";
@@ -62,6 +62,14 @@ export interface IConversation {
62
62
  contacts?: ConversationContact[];
63
63
  /** Contactos descartados por un agente; no se vuelven a sugerir ni asociar. Solo en el detalle. */
64
64
  dismissedContactIds?: string[];
65
+ /** Empresas asociadas (0..N, §15.18 CV1), independientes de contacts. */
66
+ businesses?: ConversationBusiness[];
67
+ /** Empresas descartadas por un agente; no se vuelven a asociar automáticamente. */
68
+ dismissedBusinessIds?: string[];
69
+ /** Candidatas sin asociar: limit_reached o ambiguous (CV2/CV3). Máximo CONVERSATION_MAX_PENDING_ASSOCIATIONS. */
70
+ pendingAssociations?: ConversationPendingAssociation[];
71
+ /** Candidatas que no entraron en pendingAssociations. */
72
+ pendingAssociationsOverflow?: number;
65
73
  channelInfo: Channels.IChannelInfo;
66
74
  status: ConversationStatus;
67
75
  priority: 'low' | 'normal' | 'high' | 'urgent';
@@ -139,17 +147,26 @@ export type InteractionKind = 'private' | 'wall_post' | 'comment' | 'mention';
139
147
  export declare const CONVERSATION_MAX_ADDRESSES = 50;
140
148
  /** Límite de contactos por conversación. */
141
149
  export declare const CONVERSATION_MAX_CONTACTS = 50;
150
+ /** Límite de empresas por conversación. */
151
+ export declare const CONVERSATION_MAX_BUSINESSES = 50;
152
+ /** Límite de candidatas guardadas en pendingAssociations. */
153
+ export declare const CONVERSATION_MAX_PENDING_ASSOCIATIONS = 50;
154
+ /** Origen de una asociación de contacto o empresa. */
142
155
  export type ConversationContactOrigin = 'auto_match' | 'manual' | 'migration';
143
156
  /** Dirección externa que participa del hilo. Snapshot de IChannelIdentity. */
144
157
  export interface ConversationAddress {
145
- /** IChannelIdentity.id (colección "ContactAddresses"). */
158
+ /** Id de la identidad (mismo id en ContactAddresses y ChannelIdentities, según el modelo del espacio). */
146
159
  channelIdentityId: string;
147
160
  channelType: Channels.ChannelType;
148
- /** Normalizada; clave de búsqueda. Email: completa en minúsculas. */
161
+ /** Para mostrar y compatibilidad legacy (SN1). No es clave de búsqueda: usar key/observedKey. No aplicar lowercase (NZ8). */
149
162
  address: string;
150
163
  /** Texto recibido, para mostrar. */
151
164
  originalAddress?: string | null;
152
165
  displayName?: string | null;
166
+ /** Clave principal de la identidad (namespace|scope|valor), copia de lectura refrescada (§15.24 SN1/SN2). Null en legacy hasta migrar (SN3). */
167
+ key?: string | null;
168
+ /** Clave por la que la dirección entró al hilo; inmutable, para re-resolver tras fusiones (SN2). Null en legacy hasta migrar. */
169
+ observedKey?: string | null;
153
170
  /** Cuándo la dirección entró a esta conversación. Se escribe una vez; la actividad vive en IChannelIdentity. */
154
171
  addedAt: Date;
155
172
  }
@@ -165,6 +182,26 @@ export interface ConversationContact {
165
182
  /** userId del agente; null para auto_match y migración. */
166
183
  associatedBy?: string | null;
167
184
  }
185
+ /** Empresa del CRM asociada a la conversación (CV1). Misma forma que ConversationContact. */
186
+ export interface ConversationBusiness {
187
+ businessId: string;
188
+ name?: string | null;
189
+ imageUrl?: string | null;
190
+ origin: ConversationContactOrigin | (string & {});
191
+ viaChannelIdentityIds: string[];
192
+ associatedAt: Date;
193
+ /** userId del agente; null para auto_match y migración. */
194
+ associatedBy?: string | null;
195
+ }
196
+ export type ConversationPendingAssociationReason = 'limit_reached' | 'ambiguous';
197
+ /** Candidata sin asociar guardada en la conversación (CV2/CV3). */
198
+ export interface ConversationPendingAssociation {
199
+ entityType: 'contact' | 'business';
200
+ entityId: string;
201
+ viaChannelIdentityIds: string[];
202
+ reason: ConversationPendingAssociationReason | (string & {});
203
+ detectedAt: Date;
204
+ }
168
205
  /** Límite de claves en ConversationExternalThread.keys. */
169
206
  export declare const CONVERSATION_EXTERNAL_THREAD_MAX_KEYS = 200;
170
207
  /**
@@ -197,7 +234,7 @@ export interface IWhatsAppGroupInfo {
197
234
  description: string;
198
235
  }
199
236
  export interface IWhatsAppGroupMember {
200
- contactAddress: IChannelIdentity;
237
+ contactAddress: IContactAddress;
201
238
  contactId: string;
202
239
  name: string;
203
240
  contactInfo: IContactInfo;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
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;
3
+ exports.ConversationStatus = exports.AssignMethod = exports.ConversationDirection = exports.ConversationBotStatus = exports.CONVERSATION_EXTERNAL_THREAD_MAX_KEYS = exports.CONVERSATION_MAX_PENDING_ASSOCIATIONS = exports.CONVERSATION_MAX_BUSINESSES = exports.CONVERSATION_MAX_CONTACTS = exports.CONVERSATION_MAX_ADDRESSES = void 0;
4
4
  // export enum ConversationContextType {
5
5
  // TICKET = 'TICKET',
6
6
  // CONVERSATION = 'CONVERSATION',
@@ -18,6 +18,10 @@ exports.ConversationStatus = exports.AssignMethod = exports.ConversationDirectio
18
18
  exports.CONVERSATION_MAX_ADDRESSES = 50;
19
19
  /** Límite de contactos por conversación. */
20
20
  exports.CONVERSATION_MAX_CONTACTS = 50;
21
+ /** Límite de empresas por conversación. */
22
+ exports.CONVERSATION_MAX_BUSINESSES = 50;
23
+ /** Límite de candidatas guardadas en pendingAssociations. */
24
+ exports.CONVERSATION_MAX_PENDING_ASSOCIATIONS = 50;
21
25
  /** Límite de claves en ConversationExternalThread.keys. */
22
26
  exports.CONVERSATION_EXTERNAL_THREAD_MAX_KEYS = 200;
23
27
  /** @deprecated Estado legacy. Usar ConversationAutomationStatus para ejecuciones nuevas. */
@@ -0,0 +1,22 @@
1
+ /** Colecciones de la base Conversations (§15.20 EV4). */
2
+ export declare const CONVERSATION_COLLECTIONS: {
3
+ /** Outbox único de la base Conversations. */
4
+ readonly Outbox: "Outbox";
5
+ };
6
+ /** Familia conversación↔dueño (CI-D10, EV2). aggregate = Conversation; aggregateVersion = Conversation.version. */
7
+ export type ConversationAssociationEventType = 'conversation_association.added' | 'conversation_association.removed' | 'conversation_association.dismissed' | 'conversation_association.pending_changed';
8
+ /** Payload de conversation_association.*. Nunca incluye identidades observadas solo como CCO. */
9
+ export interface ConversationAssociationEventPayload {
10
+ conversationId: string;
11
+ /** contact | business; vacío en pending_changed. */
12
+ entityType: string;
13
+ entityId: string;
14
+ origin?: string | null;
15
+ viaChannelIdentityIds: string[];
16
+ pendingCount?: number | null;
17
+ pendingOverflow?: number | null;
18
+ actor: string;
19
+ occurredAt: Date;
20
+ operationId?: string | null;
21
+ aggregateVersion: number;
22
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CONVERSATION_COLLECTIONS = void 0;
4
+ /** Colecciones de la base Conversations (§15.20 EV4). */
5
+ exports.CONVERSATION_COLLECTIONS = {
6
+ /** Outbox único de la base Conversations. */
7
+ Outbox: 'Outbox',
8
+ };
@@ -25,3 +25,4 @@ export * from './Sla';
25
25
  export * from './Transfer';
26
26
  export * from './Classifications';
27
27
  export * from './ConversationTransferRouting';
28
+ export * from './ConversationAssociationEvents';
@@ -64,3 +64,4 @@ __exportStar(require("./Sla"), exports);
64
64
  __exportStar(require("./Transfer"), exports);
65
65
  __exportStar(require("./Classifications"), exports);
66
66
  __exportStar(require("./ConversationTransferRouting"), exports);
67
+ __exportStar(require("./ConversationAssociationEvents"), exports);
@@ -16,14 +16,26 @@ export interface ISubscriber {
16
16
  id: string;
17
17
  spaceId: string;
18
18
  channelType: SubscriberChannelType;
19
- /** Normalizada igual que en Contactos: email en minúsculas; WhatsApp, solo dígitos con código de país. */
19
+ /**
20
+ * Clave de identidad del normalizador común (@trii/identity / ChannelIdentityNormalizer): email||…, wa_phone||+….
21
+ * Única por (spaceId, channelType, key) (§15.23 SB1).
22
+ */
23
+ key: string;
24
+ /** Identidad de la dirección, si ya existe en ChannelIdentities. */
25
+ channelIdentityId?: string | null;
26
+ /** Valor para mostrar. La comparación usa key. */
20
27
  address: string;
21
28
  name: string;
22
29
  lastName: string;
23
30
  company: string;
24
31
  /** Un elemento por tema en el que está o estuvo suscrito, con su último estado. */
25
32
  subscriptions: ISubscriberSubscription[];
26
- /** Contacto que tiene esta misma dirección, si se encontró uno. */
33
+ /**
34
+ * Contacto asignado explícitamente (formulario con datos de la persona o usuario de Trii). No da ni quita
35
+ * consentimiento. Los contactos de la dirección se obtienen de los dueños actuales de la identidad (SB2).
36
+ */
37
+ attributedContactId?: string | null;
38
+ /** @deprecated Vínculo singular legacy; usar attributedContactId y los dueños de la identidad (SB2). Se retira en E7. */
27
39
  contact?: ISubscriberContactLink | null;
28
40
  source: SubscriberSource;
29
41
  createdAt: CampaignTimestamp;
@@ -119,3 +131,23 @@ export interface ISubscriberDetail {
119
131
  subscriber: ISubscriber;
120
132
  signups: ISubscriberSignup[];
121
133
  }
134
+ /** Motivo de una supresión (SB4). */
135
+ export type SuppressionReason = 'complaint' | 'hard_bounce' | 'manual' | 'legal';
136
+ /**
137
+ * Supresión de envíos de Marketing (colección Suppressions de la base Marketing, §15.23 SB4). Distinta de la baja de un
138
+ * tema: bloquea campañas a esa clave aunque haya suscripción. Única por (spaceId, channelType, key); en una fusión de
139
+ * identidades se une, nunca se borra.
140
+ */
141
+ export interface ISuppression {
142
+ id: string;
143
+ spaceId: string;
144
+ channelType: SubscriberChannelType;
145
+ /** Clave de identidad del normalizador común. */
146
+ key: string;
147
+ reason: SuppressionReason;
148
+ /** Qué la originó (webhook del proveedor, usuario, importación…). */
149
+ source: string;
150
+ createdAt: CampaignTimestamp;
151
+ /** userId o system:<servicio>. */
152
+ createdBy: string;
153
+ }