@trii/types 2.10.812 → 2.10.814

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 (111) hide show
  1. package/dist/Automations/Events/Event.d.ts +3 -3
  2. package/dist/Contacts/CommunicationEndpoint.d.ts +9 -9
  3. package/dist/Conversations/Classifications/ConversationClassificationEvents.d.ts +2 -2
  4. package/dist/Conversations/Conversation.d.ts +8 -8
  5. package/dist/Conversations/InboxMongo.d.ts +154 -0
  6. package/dist/Conversations/InboxMongo.js +128 -0
  7. package/dist/Conversations/InboxProjection.d.ts +162 -0
  8. package/dist/Conversations/Routing.d.ts +10 -10
  9. package/dist/Events/DomainEventTypes.d.ts +23 -23
  10. package/dist/Presence/RoutingContracts.d.ts +33 -0
  11. package/dist/Presence/index.d.ts +1 -0
  12. package/dist/Presence/index.js +1 -0
  13. package/dist/Tickets/Api.d.ts +16 -0
  14. package/dist/Tickets/Approval.d.ts +116 -114
  15. package/dist/Tickets/Approval.js +50 -17
  16. package/dist/Tickets/Category.d.ts +8 -0
  17. package/dist/Tickets/Conversation.d.ts +12 -0
  18. package/dist/Tickets/Roles.d.ts +91 -0
  19. package/dist/Tickets/Roles.js +7 -0
  20. package/dist/Tickets/Routing.d.ts +10 -0
  21. package/dist/Tickets/Routing.js +7 -1
  22. package/dist/Tickets/Security.d.ts +34 -0
  23. package/dist/Tickets/SelfService.d.ts +17 -0
  24. package/dist/Tickets/Ticket.d.ts +24 -3
  25. package/dist/Tickets/Workflow.d.ts +47 -0
  26. package/dist/Tickets/Workflow.js +4 -0
  27. package/dist/Tickets/index.d.ts +1 -0
  28. package/dist/Tickets/index.js +1 -0
  29. package/package.json +1 -1
  30. package/dist/AI/MapPolygon.d.ts +0 -22
  31. package/dist/Conversations/DashBoard/dashboardForms.d.ts +0 -44
  32. package/dist/Conversations/DashBoard/dashboardForms.js +0 -24
  33. package/dist/Conversations/Flows/Nodes/NodeAIChatBot.d.ts +0 -0
  34. package/dist/Conversations/Flows/Nodes/NodeAIChatBot.js +0 -0
  35. package/dist/Conversations/Flows/Nodes/NodeApi.d.ts +0 -2
  36. package/dist/Conversations/Flows/Nodes/NodeApi.js +0 -183
  37. package/dist/Conversations/Flows/Nodes/NodeBotIA.d.ts +0 -15
  38. package/dist/Conversations/Flows/Nodes/NodeBotIA.js +0 -6
  39. package/dist/Conversations/Flows/Nodes/NodeChatBotIA.d.ts +0 -15
  40. package/dist/Conversations/Flows/Nodes/NodeChatBotIA.js +0 -6
  41. package/dist/Conversations/Flows/Nodes/NodeConditional.d.ts +0 -0
  42. package/dist/Conversations/Flows/Nodes/NodeConditional.js +0 -0
  43. package/dist/Conversations/Flows/Nodes/NodeContactSearch.d.ts +0 -0
  44. package/dist/Conversations/Flows/Nodes/NodeContactSearch.js +0 -0
  45. package/dist/Conversations/Flows/Nodes/NodeContactUpdate.d.ts +0 -0
  46. package/dist/Conversations/Flows/Nodes/NodeContactUpdate.js +0 -0
  47. package/dist/Conversations/Flows/Nodes/NodeConversationAssignTo.d.ts +0 -0
  48. package/dist/Conversations/Flows/Nodes/NodeConversationAssignTo.js +0 -0
  49. package/dist/Conversations/Flows/Nodes/NodeConversationFinalize.d.ts +0 -0
  50. package/dist/Conversations/Flows/Nodes/NodeConversationFinalize.js +0 -0
  51. package/dist/Conversations/Flows/Nodes/NodeConversationUpdate.d.ts +0 -0
  52. package/dist/Conversations/Flows/Nodes/NodeConversationUpdate.js +0 -0
  53. package/dist/Conversations/Flows/Nodes/NodeFillForm.d.ts +0 -0
  54. package/dist/Conversations/Flows/Nodes/NodeFillForm.js +0 -0
  55. package/dist/Conversations/Flows/Nodes/NodeFillTicket.d.ts +0 -1
  56. package/dist/Conversations/Flows/Nodes/NodeFillTicket.js +0 -9
  57. package/dist/Conversations/Flows/Nodes/NodeGoogleCalendar.d.ts +0 -20
  58. package/dist/Conversations/Flows/Nodes/NodeGoogleMaps copy.d.ts +0 -12
  59. package/dist/Conversations/Flows/Nodes/NodeGoogleMaps copy.js +0 -6
  60. package/dist/Conversations/Flows/Nodes/NodeGoogleMaps.d.ts +0 -15
  61. package/dist/Conversations/Flows/Nodes/NodeGoogleMaps.js +0 -2
  62. package/dist/Conversations/Flows/Nodes/NodeMsgReply.d.ts +0 -0
  63. package/dist/Conversations/Flows/Nodes/NodeMsgReply.js +0 -0
  64. package/dist/Conversations/Flows/Nodes/NodeMsgSend.d.ts +0 -0
  65. package/dist/Conversations/Flows/Nodes/NodeMsgSend.js +0 -0
  66. package/dist/Conversations/Flows/Nodes/NodeMsgText.d.ts +0 -1
  67. package/dist/Conversations/Flows/Nodes/NodeMsgText.js +0 -27
  68. package/dist/Conversations/Flows/Nodes/NodeMsgWaitResponse.d.ts +0 -0
  69. package/dist/Conversations/Flows/Nodes/NodeMsgWaitResponse.js +0 -0
  70. package/dist/Conversations/Flows/Nodes/NodeRedirect.d.ts +0 -0
  71. package/dist/Conversations/Flows/Nodes/NodeRedirect.js +0 -0
  72. package/dist/Conversations/Flows/Nodes/NodeSendEmail.d.ts +0 -0
  73. package/dist/Conversations/Flows/Nodes/NodeSendEmail.js +0 -0
  74. package/dist/Conversations/Flows/Nodes/NodeSqlQuery.d.ts +0 -0
  75. package/dist/Conversations/Flows/Nodes/NodeSqlQuery.js +0 -0
  76. package/dist/Conversations/Flows/Nodes/NodeStart.d.ts +0 -0
  77. package/dist/Conversations/Flows/Nodes/NodeStart.js +0 -0
  78. package/dist/Conversations/Flows/Nodes/NodeTimeScheduleControl.d.ts +0 -0
  79. package/dist/Conversations/Flows/Nodes/NodeTimeScheduleControl.js +0 -0
  80. package/dist/Conversations/Flows/Nodes/NodeTimeTimer.d.ts +0 -0
  81. package/dist/Conversations/Flows/Nodes/NodeTimeTimer.js +0 -0
  82. package/dist/Conversations/Flows/Nodes/NodeTimeWaitUntil.d.ts +0 -0
  83. package/dist/Conversations/Flows/Nodes/NodeTimeWaitUntil.js +0 -0
  84. package/dist/Conversations/Flows/Nodes/NodeToolCalculator.d.ts +0 -2
  85. package/dist/Conversations/Flows/Nodes/NodeToolCalculator.js +0 -37
  86. package/dist/Conversations/Flows/Nodes/NodeToolContacts.d.ts +0 -2
  87. package/dist/Conversations/Flows/Nodes/NodeToolContacts.js +0 -59
  88. package/dist/Conversations/Flows/Nodes/NodeToolFunction.d.ts +0 -2
  89. package/dist/Conversations/Flows/Nodes/NodeToolFunction.js +0 -45
  90. package/dist/Conversations/Flows/Nodes/NodeToolGoogleCalendar.d.ts +0 -2
  91. package/dist/Conversations/Flows/Nodes/NodeToolGoogleCalendar.js +0 -87
  92. package/dist/Conversations/Flows/Nodes/NodeToolGoogleMaps.d.ts +0 -1
  93. package/dist/Conversations/Flows/Nodes/NodeToolGoogleMaps.js +0 -2
  94. package/dist/Conversations/Flows/Nodes/NodeToolKnowledge.d.ts +0 -2
  95. package/dist/Conversations/Flows/Nodes/NodeToolKnowledge.js +0 -52
  96. package/dist/Conversations/Flows/Nodes/NodeToolMapsCheckPolygon.d.ts +0 -2
  97. package/dist/Conversations/Flows/Nodes/NodeToolMapsCheckPolygon.js +0 -59
  98. package/dist/Conversations/Flows/Nodes/NodeToolMcpClient.d.ts +0 -2
  99. package/dist/Conversations/Flows/Nodes/NodeToolMcpClient.js +0 -45
  100. package/dist/Conversations/Flows/Nodes/NodeToolShoppingCart.d.ts +0 -2
  101. package/dist/Conversations/Flows/Nodes/NodeToolShoppingCart.js +0 -81
  102. package/dist/Conversations/Flows/Nodes/index.d.ts +0 -24
  103. package/dist/Conversations/Flows/Nodes/index.js +0 -40
  104. package/dist/Conversations/InboxCounters.d.ts +0 -18
  105. package/dist/Conversations/InboxCounters.js +0 -2
  106. package/dist/Presence/ChannelRoutingState.d.ts +0 -17
  107. package/dist/Presence/ChannelRoutingState.js +0 -9
  108. package/dist/Tickets/AccessLevel.d.ts +0 -5
  109. package/dist/Tickets/AccessLevel.js +0 -9
  110. /package/dist/{AI/MapPolygon.js → Conversations/InboxProjection.js} +0 -0
  111. /package/dist/{Conversations/Flows/Nodes/NodeGoogleCalendar.js → Presence/RoutingContracts.js} +0 -0
@@ -1,8 +1,8 @@
1
1
  import { AutomationCustomer, AutomationJsonObject, AutomationJsonSchema, AutomationResourceReference, AutomationSourceApplication } from '../Common';
2
2
  export declare const AUTOMATION_MESSAGE_SCHEMAS: {
3
- readonly DOMAIN_EVENT_V1: "automations.domain-event/v1";
4
- readonly START_REQUEST_V1: "automations.start-request/v1";
5
- readonly EXECUTION_WORK_ITEM_V1: "automations.execution.work-item/v1";
3
+ readonly DOMAIN_EVENT_V1: 'automations.domain-event/v1';
4
+ readonly START_REQUEST_V1: 'automations.start-request/v1';
5
+ readonly EXECUTION_WORK_ITEM_V1: 'automations.execution.work-item/v1';
6
6
  };
7
7
  export interface AutomationEventDefinition {
8
8
  eventType: string;
@@ -9,25 +9,25 @@ export declare enum CommunicationEndpointKind {
9
9
  */
10
10
  export declare const providerIdentityNamespaces: {
11
11
  readonly meta: {
12
- readonly instagramUser: "instagram_user";
13
- readonly messengerUser: "messenger_user";
14
- readonly whatsappUser: "whatsapp_user";
12
+ readonly instagramUser: 'instagram_user';
13
+ readonly messengerUser: 'messenger_user';
14
+ readonly whatsappUser: 'whatsapp_user';
15
15
  };
16
16
  readonly telegram: {
17
- readonly user: "user";
18
- readonly chat: "chat";
17
+ readonly user: 'user';
18
+ readonly chat: 'chat';
19
19
  };
20
20
  readonly trii: {
21
- readonly webchatVisitor: "webchat_visitor";
21
+ readonly webchatVisitor: 'webchat_visitor';
22
22
  };
23
23
  readonly mercadolibre: {
24
- readonly buyer: "buyer";
24
+ readonly buyer: 'buyer';
25
25
  };
26
26
  readonly google: {
27
- readonly businessMessagesUser: "business_messages_user";
27
+ readonly businessMessagesUser: 'business_messages_user';
28
28
  };
29
29
  readonly openMessaging: {
30
- readonly user: "open_messaging_user";
30
+ readonly user: 'open_messaging_user';
31
31
  };
32
32
  };
33
33
  export type KnownIdentityProvider = keyof typeof providerIdentityNamespaces;
@@ -1,7 +1,7 @@
1
1
  import type { ConversationClassificationEvaluationStatus } from './ConversationClassificationEvaluation';
2
2
  export declare const CONVERSATION_CLASSIFICATION_EVENT_TYPES: {
3
- readonly CONVERSATION_RESOLVED_FOR_EVALUATION: "conversation.resolved-for-classification";
4
- readonly EVALUATION_FINISHED: "conversation.classification-evaluation-finished";
3
+ readonly CONVERSATION_RESOLVED_FOR_EVALUATION: 'conversation.resolved-for-classification';
4
+ readonly EVALUATION_FINISHED: 'conversation.classification-evaluation-finished';
5
5
  };
6
6
  export declare const CONVERSATION_CLASSIFICATION_EVENT_SCHEMA_VERSION: 1;
7
7
  /**
@@ -331,14 +331,14 @@ export type ConversationAssignmentSnapshot = {
331
331
  offerExpiresAt?: never;
332
332
  assignedAt?: never;
333
333
  acceptedAt?: never;
334
- } | QueuedConversationAssignmentBase & {
334
+ } | (QueuedConversationAssignmentBase & {
335
335
  status: 'queued' | 'routing';
336
336
  owner: NoConversationOwner;
337
337
  offeredAt?: never;
338
338
  offerExpiresAt?: never;
339
339
  assignedAt?: never;
340
340
  acceptedAt?: never;
341
- } | QueuedConversationAssignmentBase & {
341
+ }) | (QueuedConversationAssignmentBase & {
342
342
  status: 'offered';
343
343
  owner: UserConversationOwner;
344
344
  offeredAt: Date;
@@ -346,14 +346,14 @@ export type ConversationAssignmentSnapshot = {
346
346
  offerExpiresAt: Date;
347
347
  assignedAt?: never;
348
348
  acceptedAt?: never;
349
- } | QueuedConversationAssignmentBase & {
349
+ }) | (QueuedConversationAssignmentBase & {
350
350
  status: 'assigned';
351
351
  owner: UserConversationOwner;
352
352
  offeredAt?: null;
353
353
  offerExpiresAt?: null;
354
354
  assignedAt: Date;
355
355
  acceptedAt?: never;
356
- } | QueuedConversationAssignmentBase & {
356
+ }) | (QueuedConversationAssignmentBase & {
357
357
  status: 'accepted';
358
358
  owner: UserConversationOwner;
359
359
  /** Present after accepting an offer; absent/null when taking work directly. */
@@ -361,7 +361,7 @@ export type ConversationAssignmentSnapshot = {
361
361
  offerExpiresAt?: null;
362
362
  assignedAt: Date;
363
363
  acceptedAt: Date;
364
- };
364
+ });
365
365
  export type ActorType = 'user' | 'contact' | 'bot' | 'flow' | 'system';
366
366
  export type ParticipantRole = 'owner' | 'collaborator' | 'follower' | 'mentioned' | 'supervisor' | 'bot' | 'flow' | 'historical';
367
367
  export type ConversationEventType = 'conversation_created' | 'queued' | 'assigned' | 'accepted' | 'transferred' | 'consult_requested' | 'collaborator_added' | 'participant_added' | 'participant_removed' | 'participation_abandoned' | 'follow_started' | 'follow_stopped' | 'message_sent' | 'message_received' | 'internal_note_added' | 'bot_started' | 'bot_finished' | 'flow_started' | 'flow_finished' | 'status_changed' | 'resolved' | 'reopened' | 'sla_warning' | 'sla_breached' | 'sla_started' | 'sla_paused' | 'sla_resumed' | 'sla_met' | 'sla_overridden';
@@ -395,15 +395,15 @@ interface ConversationSubscriptionBase {
395
395
  * A subscription is persistent product intent. Assignment or participation
396
396
  * visibility must not create it unless an explicit auto-follow policy applies.
397
397
  */
398
- export type ConversationSubscription = ConversationSubscriptionBase & {
398
+ export type ConversationSubscription = (ConversationSubscriptionBase & {
399
399
  status: 'following';
400
400
  followedAt: Date;
401
401
  unfollowedAt?: never;
402
- } | ConversationSubscriptionBase & {
402
+ }) | (ConversationSubscriptionBase & {
403
403
  status: 'unfollowed';
404
404
  followedAt: Date;
405
405
  unfollowedAt: Date;
406
- };
406
+ });
407
407
  export interface PutConversationSubscriptionRequest {
408
408
  expectedVersion?: number;
409
409
  notifications: ConversationSubscriptionNotifications;
@@ -0,0 +1,154 @@
1
+ import { ID, InboxViewId } from './Conversation';
2
+ export declare const CONVERSATION_SUBSCRIPTIONS_COLLECTION = "conversation_subscriptions";
3
+ export declare const USER_INBOX_ITEMS_COLLECTION = "user_inbox_items";
4
+ export declare const USER_INBOX_COUNTERS_COLLECTION = "user_inbox_counters";
5
+ export declare const INBOX_PROCESSOR_RECEIPTS_COLLECTION = "inbox_processor_receipts";
6
+ /**
7
+ * MongoDB indexes for conversation_subscriptions.
8
+ *
9
+ * The unique index enforces one current subscription state per
10
+ * user/conversation. The follower index resolves the active followers that
11
+ * InboxAudienceResolver receives as input.
12
+ */
13
+ export declare const CONVERSATION_SUBSCRIPTION_INDEXES: readonly [{
14
+ readonly name: 'uq_subscription_user_conversation';
15
+ readonly key: {
16
+ readonly spaceId: 1;
17
+ readonly userId: 1;
18
+ readonly conversationId: 1;
19
+ };
20
+ readonly unique: true;
21
+ }, {
22
+ readonly name: 'ix_subscription_conversation_followers';
23
+ readonly key: {
24
+ readonly spaceId: 1;
25
+ readonly conversationId: 1;
26
+ readonly status: 1;
27
+ readonly userId: 1;
28
+ };
29
+ }];
30
+ /**
31
+ * MongoDB indexes for user_inbox_items.
32
+ *
33
+ * views.viewId is the only array field in each compound index. Do not add
34
+ * views.visibilityReasons to these indexes: MongoDB compound multikey indexes
35
+ * must not combine multiple array paths.
36
+ */
37
+ export declare const USER_INBOX_ITEM_INDEXES: readonly [{
38
+ readonly name: 'uq_inbox_item_user_conversation';
39
+ readonly key: {
40
+ readonly spaceId: 1;
41
+ readonly userId: 1;
42
+ readonly conversationId: 1;
43
+ };
44
+ readonly unique: true;
45
+ }, {
46
+ readonly name: 'ix_inbox_view_activity';
47
+ readonly key: {
48
+ readonly spaceId: 1;
49
+ readonly userId: 1;
50
+ readonly 'views.viewId': 1;
51
+ readonly pinned: -1;
52
+ readonly sortAt: -1;
53
+ readonly id: -1;
54
+ };
55
+ }, {
56
+ readonly name: 'ix_inbox_view_priority';
57
+ readonly key: {
58
+ readonly spaceId: 1;
59
+ readonly userId: 1;
60
+ readonly 'views.viewId': 1;
61
+ readonly pinned: -1;
62
+ readonly priorityScore: -1;
63
+ readonly sortAt: -1;
64
+ readonly id: -1;
65
+ };
66
+ }, {
67
+ readonly name: 'ix_inbox_view_status_activity';
68
+ readonly key: {
69
+ readonly spaceId: 1;
70
+ readonly userId: 1;
71
+ readonly 'views.viewId': 1;
72
+ readonly 'snapshot.status': 1;
73
+ readonly sortAt: -1;
74
+ readonly id: -1;
75
+ };
76
+ }, {
77
+ readonly name: 'ix_inbox_view_queue_activity';
78
+ readonly key: {
79
+ readonly spaceId: 1;
80
+ readonly userId: 1;
81
+ readonly 'views.viewId': 1;
82
+ readonly 'snapshot.queueId': 1;
83
+ readonly sortAt: -1;
84
+ readonly id: -1;
85
+ };
86
+ }];
87
+ /**
88
+ * MongoDB indexes for user_inbox_counters.
89
+ *
90
+ * The unique index also serves reads for all views of a user through its
91
+ * spaceId + userId prefix.
92
+ */
93
+ export declare const USER_INBOX_COUNTER_INDEXES: readonly [{
94
+ readonly name: 'uq_inbox_counter_user_view';
95
+ readonly key: {
96
+ readonly spaceId: 1;
97
+ readonly userId: 1;
98
+ readonly viewId: 1;
99
+ };
100
+ readonly unique: true;
101
+ }];
102
+ /**
103
+ * MongoDB indexes for durable processor idempotency receipts.
104
+ */
105
+ export declare const INBOX_PROCESSOR_RECEIPT_INDEXES: readonly [{
106
+ readonly name: 'uq_inbox_processor_source_scope';
107
+ readonly key: {
108
+ readonly processor: 1;
109
+ readonly sourceEventId: 1;
110
+ readonly scopeKey: 1;
111
+ };
112
+ readonly unique: true;
113
+ }];
114
+ export type InboxPaginationSort = 'activity' | 'priority';
115
+ /**
116
+ * Seek-pagination cursor matching ix_inbox_view_activity.
117
+ */
118
+ export interface InboxActivityCursor {
119
+ sort: 'activity';
120
+ pinned: boolean;
121
+ sortAt: Date;
122
+ id: ID;
123
+ }
124
+ /**
125
+ * Seek-pagination cursor matching ix_inbox_view_priority.
126
+ */
127
+ export interface InboxPriorityCursor {
128
+ sort: 'priority';
129
+ pinned: boolean;
130
+ priorityScore: number;
131
+ sortAt: Date;
132
+ id: ID;
133
+ }
134
+ export type InboxPaginationCursor = InboxActivityCursor | InboxPriorityCursor;
135
+ /**
136
+ * Query contract for one logical inbox view.
137
+ *
138
+ * Implementations must use seek pagination with cursor; skip pagination is not
139
+ * compatible with frequently changing sortAt values.
140
+ */
141
+ interface InboxPageQueryBase {
142
+ spaceId: ID;
143
+ userId: ID;
144
+ viewId: InboxViewId;
145
+ limit: number;
146
+ }
147
+ export type InboxPageQuery = (InboxPageQueryBase & {
148
+ sort: 'activity';
149
+ cursor?: InboxActivityCursor;
150
+ }) | (InboxPageQueryBase & {
151
+ sort: 'priority';
152
+ cursor?: InboxPriorityCursor;
153
+ });
154
+ export {};
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.INBOX_PROCESSOR_RECEIPT_INDEXES = exports.USER_INBOX_COUNTER_INDEXES = exports.USER_INBOX_ITEM_INDEXES = exports.CONVERSATION_SUBSCRIPTION_INDEXES = exports.INBOX_PROCESSOR_RECEIPTS_COLLECTION = exports.USER_INBOX_COUNTERS_COLLECTION = exports.USER_INBOX_ITEMS_COLLECTION = exports.CONVERSATION_SUBSCRIPTIONS_COLLECTION = void 0;
4
+ exports.CONVERSATION_SUBSCRIPTIONS_COLLECTION = 'conversation_subscriptions';
5
+ exports.USER_INBOX_ITEMS_COLLECTION = 'user_inbox_items';
6
+ exports.USER_INBOX_COUNTERS_COLLECTION = 'user_inbox_counters';
7
+ exports.INBOX_PROCESSOR_RECEIPTS_COLLECTION = 'inbox_processor_receipts';
8
+ /**
9
+ * MongoDB indexes for conversation_subscriptions.
10
+ *
11
+ * The unique index enforces one current subscription state per
12
+ * user/conversation. The follower index resolves the active followers that
13
+ * InboxAudienceResolver receives as input.
14
+ */
15
+ exports.CONVERSATION_SUBSCRIPTION_INDEXES = [
16
+ {
17
+ name: 'uq_subscription_user_conversation',
18
+ key: {
19
+ spaceId: 1,
20
+ userId: 1,
21
+ conversationId: 1,
22
+ },
23
+ unique: true,
24
+ },
25
+ {
26
+ name: 'ix_subscription_conversation_followers',
27
+ key: {
28
+ spaceId: 1,
29
+ conversationId: 1,
30
+ status: 1,
31
+ userId: 1,
32
+ },
33
+ },
34
+ ];
35
+ /**
36
+ * MongoDB indexes for user_inbox_items.
37
+ *
38
+ * views.viewId is the only array field in each compound index. Do not add
39
+ * views.visibilityReasons to these indexes: MongoDB compound multikey indexes
40
+ * must not combine multiple array paths.
41
+ */
42
+ exports.USER_INBOX_ITEM_INDEXES = [
43
+ {
44
+ name: 'uq_inbox_item_user_conversation',
45
+ key: {
46
+ spaceId: 1,
47
+ userId: 1,
48
+ conversationId: 1,
49
+ },
50
+ unique: true,
51
+ },
52
+ {
53
+ name: 'ix_inbox_view_activity',
54
+ key: {
55
+ spaceId: 1,
56
+ userId: 1,
57
+ 'views.viewId': 1,
58
+ pinned: -1,
59
+ sortAt: -1,
60
+ id: -1,
61
+ },
62
+ },
63
+ {
64
+ name: 'ix_inbox_view_priority',
65
+ key: {
66
+ spaceId: 1,
67
+ userId: 1,
68
+ 'views.viewId': 1,
69
+ pinned: -1,
70
+ priorityScore: -1,
71
+ sortAt: -1,
72
+ id: -1,
73
+ },
74
+ },
75
+ {
76
+ name: 'ix_inbox_view_status_activity',
77
+ key: {
78
+ spaceId: 1,
79
+ userId: 1,
80
+ 'views.viewId': 1,
81
+ 'snapshot.status': 1,
82
+ sortAt: -1,
83
+ id: -1,
84
+ },
85
+ },
86
+ {
87
+ name: 'ix_inbox_view_queue_activity',
88
+ key: {
89
+ spaceId: 1,
90
+ userId: 1,
91
+ 'views.viewId': 1,
92
+ 'snapshot.queueId': 1,
93
+ sortAt: -1,
94
+ id: -1,
95
+ },
96
+ },
97
+ ];
98
+ /**
99
+ * MongoDB indexes for user_inbox_counters.
100
+ *
101
+ * The unique index also serves reads for all views of a user through its
102
+ * spaceId + userId prefix.
103
+ */
104
+ exports.USER_INBOX_COUNTER_INDEXES = [
105
+ {
106
+ name: 'uq_inbox_counter_user_view',
107
+ key: {
108
+ spaceId: 1,
109
+ userId: 1,
110
+ viewId: 1,
111
+ },
112
+ unique: true,
113
+ },
114
+ ];
115
+ /**
116
+ * MongoDB indexes for durable processor idempotency receipts.
117
+ */
118
+ exports.INBOX_PROCESSOR_RECEIPT_INDEXES = [
119
+ {
120
+ name: 'uq_inbox_processor_source_scope',
121
+ key: {
122
+ processor: 1,
123
+ sourceEventId: 1,
124
+ scopeKey: 1,
125
+ },
126
+ unique: true,
127
+ },
128
+ ];
@@ -0,0 +1,162 @@
1
+ import { ConversationInboxSnapshot, ID, InboxViewId, UserInboxItemView } from './Conversation';
2
+ import { ConversationQueue } from './Queue';
3
+ import { ConversationAssignmentChanged } from './Transfer';
4
+ export type InboxProcessorName = 'inbox-audience-resolver' | 'inbox-item-projector' | 'inbox-counter-projector';
5
+ /**
6
+ * Queue membership snapshot used while resolving an assignment change.
7
+ *
8
+ * Produced by: assignment-change consumer.
9
+ * Consumed by: InboxAudienceResolver.
10
+ * Used when: previous/current queue audiences must be expanded from groups
11
+ * into concrete users without embedding membership in the integration event.
12
+ */
13
+ export interface QueueAudienceResolutionContext {
14
+ queue: ConversationQueue;
15
+ memberUserIds: ID[];
16
+ activeMemberUserIds: ID[];
17
+ supervisorUserIds: ID[];
18
+ }
19
+ /**
20
+ * Complete input for calculating desired inbox visibility.
21
+ *
22
+ * Produced by: ConversationAssignmentChanged consumer.
23
+ * Consumed by: InboxAudienceResolver.
24
+ * Used when: an assignment/transfer changes queue, owner or status and the
25
+ * desired per-user inbox audience must be recalculated.
26
+ */
27
+ export interface InboxAudienceResolverInput {
28
+ sourceEvent: ConversationAssignmentChanged;
29
+ snapshot: ConversationInboxSnapshot;
30
+ previousQueue?: QueueAudienceResolutionContext;
31
+ currentQueue?: QueueAudienceResolutionContext;
32
+ participantUserIds: ID[];
33
+ followerUserIds: ID[];
34
+ }
35
+ /**
36
+ * Visibility of one conversation inside one logical inbox view.
37
+ *
38
+ * Produced by: InboxAudienceResolver.
39
+ * Consumed by: inbox item projection planner/projector.
40
+ * Used when: multiple independent reasons can preserve the same view without
41
+ * generating duplicate inbox items or duplicate counter increments.
42
+ */
43
+ export type ResolvedInboxView = UserInboxItemView;
44
+ /**
45
+ * Desired inbox visibility for a single user after applying the source event.
46
+ *
47
+ * Produced by: InboxAudienceResolver.
48
+ * Consumed by: inbox item projection planner/projector.
49
+ * Used when: the projector compares desired visibility with the materialized
50
+ * user_inbox_items state.
51
+ */
52
+ export interface ResolvedInboxUserVisibility {
53
+ userId: ID;
54
+ views: ResolvedInboxView[];
55
+ }
56
+ /**
57
+ * Full audience resolution result for one conversation version.
58
+ *
59
+ * Produced by: InboxAudienceResolver.
60
+ * Consumed by: inbox item projection planner/projector.
61
+ * Used when: all affected users must be diffed against their existing
62
+ * user_inbox_items documents.
63
+ */
64
+ export interface ResolvedInboxAudience {
65
+ sourceEventId: ID;
66
+ spaceId: ID;
67
+ conversationId: ID;
68
+ conversationVersion: number;
69
+ snapshot: ConversationInboxSnapshot;
70
+ users: ResolvedInboxUserVisibility[];
71
+ resolvedAt: Date;
72
+ }
73
+ /**
74
+ * Processor boundary for pure audience calculation.
75
+ *
76
+ * Called by: ConversationAssignmentChanged consumer.
77
+ * Returns to: inbox item projection planner/projector.
78
+ */
79
+ export interface InboxAudienceResolver {
80
+ resolve(input: InboxAudienceResolverInput): Promise<ResolvedInboxAudience>;
81
+ }
82
+ export type InboxProjectionOperation = 'insert' | 'update' | 'delete';
83
+ /**
84
+ * Idempotent mutation plan for one user's materialized conversation item.
85
+ *
86
+ * Produced by: inbox item projection planner.
87
+ * Consumed by: inbox item projector; after persistence it is also the input
88
+ * used to derive InboxCounterDelta messages.
89
+ * Used when: desired audience is compared with the existing projection.
90
+ *
91
+ * id must be deterministic from:
92
+ * sourceEventId + userId + conversationId.
93
+ */
94
+ export interface InboxProjectionDelta {
95
+ id: ID;
96
+ sourceEventId: ID;
97
+ spaceId: ID;
98
+ userId: ID;
99
+ conversationId: ID;
100
+ conversationVersion: number;
101
+ operation: InboxProjectionOperation;
102
+ previous?: ResolvedInboxUserVisibility;
103
+ current?: ResolvedInboxUserVisibility;
104
+ snapshot?: ConversationInboxSnapshot;
105
+ createdAt: Date;
106
+ }
107
+ /**
108
+ * Atomic counter change for one user/view caused by one projection delta.
109
+ *
110
+ * Produced by: inbox item projector after determining the actual persisted
111
+ * before/after state.
112
+ * Consumed by: InboxCounterProjector.
113
+ * Used when: view membership, requiresAction or unread state changes.
114
+ *
115
+ * id must be deterministic from:
116
+ * sourceEventId + userId + conversationId + viewId.
117
+ */
118
+ export interface InboxCounterDelta {
119
+ id: ID;
120
+ sourceEventId: ID;
121
+ spaceId: ID;
122
+ userId: ID;
123
+ conversationId: ID;
124
+ viewId: InboxViewId;
125
+ conversationVersion: number;
126
+ totalDelta: -1 | 0 | 1;
127
+ requiresActionDelta: -1 | 0 | 1;
128
+ unreadDelta: -1 | 0 | 1;
129
+ createdAt: Date;
130
+ }
131
+ /**
132
+ * Durable idempotency receipt for a processor side effect.
133
+ *
134
+ * Produced and consumed by: inbox item projector or InboxCounterProjector.
135
+ * Used when: the same outbox event/delta is delivered more than once.
136
+ *
137
+ * Unique key:
138
+ * processor + sourceEventId + scopeKey.
139
+ *
140
+ * scopeKey examples:
141
+ * - item projector: userId + conversationId
142
+ * - counter projector: userId + conversationId + viewId
143
+ */
144
+ export interface InboxProcessorReceipt {
145
+ id: ID;
146
+ processor: InboxProcessorName;
147
+ sourceEventId: ID;
148
+ scopeKey: string;
149
+ spaceId: ID;
150
+ conversationId: ID;
151
+ conversationVersion: number;
152
+ processedAt: Date;
153
+ }
154
+ /**
155
+ * Processor boundary for applying counter deltas idempotently.
156
+ *
157
+ * Called by: inbox item projector.
158
+ * Mutates: user_inbox_counters and InboxProcessorReceipt in one transaction.
159
+ */
160
+ export interface InboxCounterProjector {
161
+ apply(delta: InboxCounterDelta): Promise<void>;
162
+ }
@@ -21,27 +21,27 @@ export interface PartyOwnerAssigneeResolver {
21
21
  mode: 'prefer' | 'required';
22
22
  }
23
23
  export type QueueOwnerAssigneeResolver = PartyOwnerAssigneeResolver;
24
- export type QueueRoutingPolicy = QueueRoutingPolicyBase & {
24
+ export type QueueRoutingPolicy = (QueueRoutingPolicyBase & {
25
25
  distributionMode: 'shared';
26
26
  strategy?: never;
27
27
  ownerResolver?: never;
28
- } | QueueRoutingPolicyBase & {
28
+ }) | (QueueRoutingPolicyBase & {
29
29
  distributionMode: 'manual_pull';
30
30
  strategy?: never;
31
31
  ownerResolver?: never;
32
- } | QueueRoutingPolicyBase & {
32
+ }) | (QueueRoutingPolicyBase & {
33
33
  distributionMode: 'exclusive';
34
34
  strategy: QueueRoutingStrategy;
35
- ownerResolver?: undefined | PartyOwnerAssigneeResolver & {
35
+ ownerResolver?: undefined | (PartyOwnerAssigneeResolver & {
36
36
  mode: 'prefer';
37
- };
38
- } | QueueRoutingPolicyBase & {
37
+ });
38
+ }) | (QueueRoutingPolicyBase & {
39
39
  distributionMode: 'exclusive';
40
40
  strategy?: never;
41
41
  ownerResolver: PartyOwnerAssigneeResolver & {
42
42
  mode: 'required';
43
43
  };
44
- };
44
+ });
45
45
  export type QueueRoutingConfig = QueueRoutingPolicy & {
46
46
  queueId: string;
47
47
  spaceId: string;
@@ -128,15 +128,15 @@ export type PartyOwnerAssigneeEvaluation = {
128
128
  }>;
129
129
  outcome: 'selected';
130
130
  nextStep?: never;
131
- } | FailedPartyOwnerEvaluation & {
131
+ } | (FailedPartyOwnerEvaluation & {
132
132
  type: 'party_owner';
133
133
  mode: 'prefer';
134
134
  nextStep: 'strategy';
135
- } | FailedPartyOwnerEvaluation & {
135
+ }) | (FailedPartyOwnerEvaluation & {
136
136
  type: 'party_owner';
137
137
  mode: 'required';
138
138
  nextStep: 'fallback';
139
- };
139
+ });
140
140
  export interface RoutingDecision {
141
141
  decisionId: string;
142
142
  spaceId: string;
@@ -9,39 +9,39 @@
9
9
  */
10
10
  export declare const DOMAIN_EVENT_TYPES: {
11
11
  readonly AUTOMATIONS: {
12
- readonly MANUAL: "automations.manual";
13
- readonly SCHEDULE_TICK: "automations.schedule.tick";
12
+ readonly MANUAL: 'automations.manual';
13
+ readonly SCHEDULE_TICK: 'automations.schedule.tick';
14
14
  };
15
15
  readonly CONTACTS: {
16
- readonly CONTACT_CREATED: "contacts.contact.created";
17
- readonly BUSINESS_CREATED: "contacts.business.created";
18
- readonly PROPERTY_CHANGED: "contacts.property.changed";
19
- readonly TAG_ADDED: "contacts.tag.added";
20
- readonly TAG_REMOVED: "contacts.tag.removed";
21
- readonly PROPERTY_DATE_REACHED: "contacts.property.date_reached";
16
+ readonly CONTACT_CREATED: 'contacts.contact.created';
17
+ readonly BUSINESS_CREATED: 'contacts.business.created';
18
+ readonly PROPERTY_CHANGED: 'contacts.property.changed';
19
+ readonly TAG_ADDED: 'contacts.tag.added';
20
+ readonly TAG_REMOVED: 'contacts.tag.removed';
21
+ readonly PROPERTY_DATE_REACHED: 'contacts.property.date_reached';
22
22
  };
23
23
  readonly CONVERSATIONS: {
24
- readonly CONVERSATION_CREATED: "conversations.conversation.created";
25
- readonly CONVERSATION_CLOSED: "conversations.conversation.closed";
26
- readonly MESSAGE_RECEIVED: "conversations.message.received";
27
- readonly AGENT_INTERVENED: "conversations.agent.intervened";
24
+ readonly CONVERSATION_CREATED: 'conversations.conversation.created';
25
+ readonly CONVERSATION_CLOSED: 'conversations.conversation.closed';
26
+ readonly MESSAGE_RECEIVED: 'conversations.message.received';
27
+ readonly AGENT_INTERVENED: 'conversations.agent.intervened';
28
28
  };
29
29
  readonly TICKETS: {
30
- readonly CREATED: "tickets.created";
31
- readonly STATUS_CHANGED: "tickets.status_changed";
32
- readonly PRIORITY_CHANGED: "tickets.priority_changed";
33
- readonly ASSIGNED: "tickets.assigned";
34
- readonly CUSTOMER_REPLIED: "tickets.customer_replied";
35
- readonly SLA_WARNING: "tickets.sla_warning";
36
- readonly SLA_BREACHED: "tickets.sla_breached";
37
- readonly CLOSED: "tickets.closed";
38
- readonly REOPENED: "tickets.reopened";
30
+ readonly CREATED: 'tickets.created';
31
+ readonly STATUS_CHANGED: 'tickets.status_changed';
32
+ readonly PRIORITY_CHANGED: 'tickets.priority_changed';
33
+ readonly ASSIGNED: 'tickets.assigned';
34
+ readonly CUSTOMER_REPLIED: 'tickets.customer_replied';
35
+ readonly SLA_WARNING: 'tickets.sla_warning';
36
+ readonly SLA_BREACHED: 'tickets.sla_breached';
37
+ readonly CLOSED: 'tickets.closed';
38
+ readonly REOPENED: 'tickets.reopened';
39
39
  };
40
40
  readonly FORMS: {
41
- readonly SUBMITTED: "forms.submitted";
41
+ readonly SUBMITTED: 'forms.submitted';
42
42
  };
43
43
  readonly INTEGRATIONS: {
44
- readonly WEBHOOK_RECEIVED: "integrations.webhook.received";
44
+ readonly WEBHOOK_RECEIVED: 'integrations.webhook.received';
45
45
  };
46
46
  };
47
47
  type Values<T> = T extends unknown ? T[keyof T] : never;