@trii/types 2.10.675 → 2.10.677

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.
@@ -0,0 +1,163 @@
1
+ interface QueueRoutingPolicyBase {
2
+ requiredSkills?: string[];
3
+ optionalSkills?: string[];
4
+ acceptedChannels: string[];
5
+ requireActiveParticipation: boolean;
6
+ requireAvailablePresence: boolean;
7
+ requireAcceptance: boolean;
8
+ capacityPolicy: {
9
+ maxConcurrentByChannel: Record<string, number>;
10
+ weightByChannel: Record<string, number>;
11
+ };
12
+ fallback: {
13
+ action: 'keep_queued' | 'overflow_queue' | 'assign_supervisor';
14
+ overflowQueueId?: string;
15
+ timeoutSeconds?: number;
16
+ };
17
+ }
18
+ /**
19
+ * Resolves the ownerUserId of the contact or business associated with the
20
+ * conversation. The resolved user is still subject to every Queue eligibility
21
+ * rule.
22
+ */
23
+ export interface PartyOwnerAssigneeResolver {
24
+ type: 'party_owner';
25
+ mode: 'prefer' | 'required';
26
+ }
27
+ export type QueueOwnerAssigneeResolver = PartyOwnerAssigneeResolver;
28
+ export type QueueRoutingPolicy = QueueRoutingPolicyBase & {
29
+ distributionMode: 'shared';
30
+ strategy?: never;
31
+ ownerResolver?: never;
32
+ } | QueueRoutingPolicyBase & {
33
+ distributionMode: 'manual_pull';
34
+ strategy?: never;
35
+ ownerResolver?: never;
36
+ } | QueueRoutingPolicyBase & {
37
+ distributionMode: 'exclusive';
38
+ strategy: QueueRoutingStrategy;
39
+ ownerResolver?: undefined | PartyOwnerAssigneeResolver & {
40
+ mode: 'prefer';
41
+ };
42
+ } | QueueRoutingPolicyBase & {
43
+ distributionMode: 'exclusive';
44
+ strategy?: never;
45
+ ownerResolver: PartyOwnerAssigneeResolver & {
46
+ mode: 'required';
47
+ };
48
+ };
49
+ export type QueueRoutingConfig = QueueRoutingPolicy & {
50
+ queueId: string;
51
+ spaceId: string;
52
+ version: number;
53
+ updatedAt: Date;
54
+ };
55
+ export type QueueDistributionMode = 'shared' | 'exclusive' | 'manual_pull';
56
+ export type QueueRoutingStrategy = 'round_robin' | 'least_busy' | 'random' | 'highest_capacity' | 'skills' | 'account_affinity' | 'longest_idle' | 'manual';
57
+ export interface RoutingCandidate {
58
+ userId: string;
59
+ queueId: string;
60
+ authorized: boolean;
61
+ participating: boolean;
62
+ available: boolean;
63
+ channelEligible: boolean;
64
+ capacityUsed: number;
65
+ capacityTotal: number;
66
+ lastAssignedAt?: Date;
67
+ idleSince?: Date;
68
+ skills: string[];
69
+ accountAffinityScore?: number;
70
+ }
71
+ export type RoutingPartyType = 'contact' | 'business';
72
+ /**
73
+ * Snapshot resolved by the command producer. The routing worker must not read
74
+ * Contacts again to obtain ownerUserId.
75
+ */
76
+ export type RoutingPartyContext = {
77
+ status: 'not_found';
78
+ partyType: RoutingPartyType;
79
+ partyId?: string;
80
+ ownerUserId?: never;
81
+ } | {
82
+ status: 'without_owner';
83
+ partyType: RoutingPartyType;
84
+ partyId: string;
85
+ ownerUserId?: never;
86
+ } | {
87
+ status: 'resolved';
88
+ partyType: RoutingPartyType;
89
+ partyId: string;
90
+ ownerUserId: string;
91
+ };
92
+ /**
93
+ * Idempotent request for routing a queued conversation.
94
+ *
95
+ * contact/business ownership is captured in party by the producer so the
96
+ * routing worker can evaluate it against candidates without another read.
97
+ */
98
+ export interface RouteConversationCommand {
99
+ commandId: string;
100
+ sourceEventId: string;
101
+ spaceId: string;
102
+ conversationId: string;
103
+ queueId: string;
104
+ expectedConversationVersion: number;
105
+ queueConfigVersion: number;
106
+ party: RoutingPartyContext;
107
+ requestedAt: Date;
108
+ }
109
+ export type RoutingSelectionSource = 'party_owner' | 'strategy' | 'fallback';
110
+ export type PartyOwnerResolutionFailure = 'party_not_found' | 'party_without_owner' | 'owner_user_not_found' | 'not_authorized' | 'not_participating' | 'unavailable' | 'channel_ineligible' | 'capacity_exhausted';
111
+ type FailedPartyOwnerEvaluation = {
112
+ party: Extract<RoutingPartyContext, {
113
+ status: 'not_found';
114
+ }>;
115
+ outcome: 'party_not_found';
116
+ } | {
117
+ party: Extract<RoutingPartyContext, {
118
+ status: 'without_owner';
119
+ }>;
120
+ outcome: 'party_without_owner';
121
+ } | {
122
+ party: Extract<RoutingPartyContext, {
123
+ status: 'resolved';
124
+ }>;
125
+ outcome: Exclude<PartyOwnerResolutionFailure, 'party_not_found' | 'party_without_owner'>;
126
+ };
127
+ export type PartyOwnerAssigneeEvaluation = {
128
+ type: 'party_owner';
129
+ mode: PartyOwnerAssigneeResolver['mode'];
130
+ party: Extract<RoutingPartyContext, {
131
+ status: 'resolved';
132
+ }>;
133
+ outcome: 'selected';
134
+ nextStep?: never;
135
+ } | FailedPartyOwnerEvaluation & {
136
+ type: 'party_owner';
137
+ mode: 'prefer';
138
+ nextStep: 'strategy';
139
+ } | FailedPartyOwnerEvaluation & {
140
+ type: 'party_owner';
141
+ mode: 'required';
142
+ nextStep: 'fallback';
143
+ };
144
+ export interface RoutingDecision {
145
+ decisionId: string;
146
+ spaceId: string;
147
+ conversationId: string;
148
+ queueId: string;
149
+ distributionMode: QueueDistributionMode;
150
+ strategy?: QueueRoutingStrategy;
151
+ eligibleUserIds: string[];
152
+ selectedUserId?: string;
153
+ selectionSource?: RoutingSelectionSource;
154
+ ownerEvaluation?: PartyOwnerAssigneeEvaluation;
155
+ rejected: Array<{
156
+ userId: string;
157
+ reasons: string[];
158
+ }>;
159
+ queueConfigVersion: number;
160
+ conversationVersion: number;
161
+ createdAt: Date;
162
+ }
163
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,73 @@
1
+ import { OutboxEvent } from './Outbox';
2
+ import { AssignmentActorReference, AssignmentStateReference, ConversationAssignmentReason } from './Assignment';
3
+ import { ID } from './Conversation';
4
+ export type TransferConversationReason = Extract<ConversationAssignmentReason, 'manual_transfer' | 'flow_routing' | 'sla_escalation' | 'system_recovery'>;
5
+ export type TransferConversationTarget = {
6
+ type: 'queue';
7
+ queueId: ID;
8
+ } | {
9
+ type: 'user';
10
+ queueId: ID;
11
+ userId: ID;
12
+ };
13
+ export interface TransferConversationCommand {
14
+ commandId: ID;
15
+ spaceId: ID;
16
+ conversationId: ID;
17
+ target: TransferConversationTarget;
18
+ expectedConversationVersion: number;
19
+ actor: AssignmentActorReference;
20
+ reason: TransferConversationReason;
21
+ requestedAt: Date;
22
+ }
23
+ export type TransferConversationRejectionCode = 'conversation_not_found' | 'target_queue_not_found' | 'target_queue_disabled' | 'target_user_not_found' | 'target_user_not_authorized' | 'target_user_not_available' | 'target_user_has_no_capacity' | 'channel_not_supported' | 'same_queue' | 'same_owner' | 'actor_not_authorized' | 'conversation_not_transferable';
24
+ export type TransferConversationResult = {
25
+ status: 'transferred';
26
+ commandId: ID;
27
+ conversationId: ID;
28
+ previousVersion: number;
29
+ conversationVersion: number;
30
+ previous: AssignmentStateReference;
31
+ current: AssignmentStateReference;
32
+ assignmentEventId: ID;
33
+ outboxEventId: ID;
34
+ } | {
35
+ status: 'already_applied';
36
+ commandId: ID;
37
+ conversationId: ID;
38
+ conversationVersion: number;
39
+ assignmentEventId: ID;
40
+ outboxEventId: ID;
41
+ } | {
42
+ status: 'version_conflict';
43
+ commandId: ID;
44
+ conversationId: ID;
45
+ expectedVersion: number;
46
+ currentVersion: number;
47
+ } | {
48
+ status: 'rejected';
49
+ commandId: ID;
50
+ conversationId: ID;
51
+ code: TransferConversationRejectionCode;
52
+ };
53
+ export interface ConversationAssignmentChanged {
54
+ eventId: ID;
55
+ sourceEventId: ID;
56
+ type: 'conversation.assignment.changed';
57
+ schemaVersion: 1;
58
+ spaceId: ID;
59
+ conversationId: ID;
60
+ conversationVersion: number;
61
+ reason: ConversationAssignmentReason;
62
+ previous?: AssignmentStateReference;
63
+ current: AssignmentStateReference;
64
+ actor: AssignmentActorReference;
65
+ correlationId: ID;
66
+ causationId: ID;
67
+ occurredAt: Date;
68
+ }
69
+ export type ConversationAssignmentChangedOutboxEvent = OutboxEvent<ConversationAssignmentChanged> & {
70
+ aggregateType: 'conversation';
71
+ eventType: 'conversation.assignment.changed';
72
+ schemaVersion: 1;
73
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -5,7 +5,7 @@ import { AuthType } from '../Common/API/AuthType';
5
5
  import { Method } from '../Common/API/Method';
6
6
  interface IWebhook {
7
7
  id?: string | null;
8
- tenantId?: string | null;
8
+ spaceId?: string | null;
9
9
  name?: string | null;
10
10
  apiUrl?: string | null;
11
11
  apiMethod?: Method | null;
@@ -1,7 +1,10 @@
1
1
  export * as Flows from './Flows/index';
2
2
  export * as Groups from './Groups/Group';
3
+ export * from './Assignment';
3
4
  export * from './Conversation';
4
- export * from './InboxCounters';
5
+ export * from './InboxMongo';
6
+ export * from './InboxProjection';
7
+ export * from './Outbox';
5
8
  export * from './Ending';
6
9
  export * from './Label';
7
10
  export * from './WebHook';
@@ -12,3 +15,6 @@ export * from '../Forms/API';
12
15
  export * from './DashBoard/dashboardChannels';
13
16
  export * from './DashBoard/dashboardMessages';
14
17
  export * from './Survey';
18
+ export * from './Queue';
19
+ export * from './Routing';
20
+ export * from './Transfer';
@@ -39,8 +39,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.Groups = exports.Flows = void 0;
40
40
  exports.Flows = __importStar(require("./Flows/index"));
41
41
  exports.Groups = __importStar(require("./Groups/Group"));
42
+ __exportStar(require("./Assignment"), exports);
42
43
  __exportStar(require("./Conversation"), exports);
43
- __exportStar(require("./InboxCounters"), exports);
44
+ __exportStar(require("./InboxMongo"), exports);
45
+ __exportStar(require("./InboxProjection"), exports);
46
+ __exportStar(require("./Outbox"), exports);
44
47
  __exportStar(require("./Ending"), exports);
45
48
  __exportStar(require("./Label"), exports);
46
49
  __exportStar(require("./WebHook"), exports);
@@ -51,3 +54,6 @@ __exportStar(require("../Forms/API"), exports);
51
54
  __exportStar(require("./DashBoard/dashboardChannels"), exports);
52
55
  __exportStar(require("./DashBoard/dashboardMessages"), exports);
53
56
  __exportStar(require("./Survey"), exports);
57
+ __exportStar(require("./Queue"), exports);
58
+ __exportStar(require("./Routing"), exports);
59
+ __exportStar(require("./Transfer"), exports);
@@ -1,4 +1,4 @@
1
- import { GroupInfo } from "../Conversations/Groups/Group";
1
+ import { ConversationQueueInfo } from "../Conversations/Queue";
2
2
  export interface QueueParticipation {
3
3
  spaceId: string;
4
4
  userId: string;
@@ -13,5 +13,5 @@ export interface QueueParticipationDto {
13
13
  authorized: boolean;
14
14
  active: boolean;
15
15
  updatedAt: Date;
16
- queue?: GroupInfo | null;
16
+ queue?: ConversationQueueInfo | null;
17
17
  }
@@ -1,4 +1,4 @@
1
- import { GroupInfo } from "../Conversations/Groups/Group";
1
+ import { ConversationQueueInfo } from "../Conversations/Queue";
2
2
  export interface QueueRoutingState {
3
3
  spaceId: string;
4
4
  userId: string;
@@ -17,7 +17,7 @@ export declare enum RoutingPresenceStatus {
17
17
  }
18
18
  export interface RoutingStateDto {
19
19
  queueId: string;
20
- queue?: GroupInfo | null;
20
+ queue?: ConversationQueueInfo | null;
21
21
  isEligible: boolean;
22
22
  presenceStatus?: RoutingPresenceStatus;
23
23
  activeJobCount: number;
@@ -323,6 +323,32 @@ export interface ITicketDashboard {
323
323
  updatedAt?: Date;
324
324
  updatedBy?: string;
325
325
  }
326
+ export interface ICreateTicketDashboardDto {
327
+ name: string;
328
+ description?: string;
329
+ audience: TicketAnalyticsAudience;
330
+ visibility: TicketDashboardVisibility;
331
+ sharedRoleIds?: string[];
332
+ sharedGroupIds?: string[];
333
+ defaultFilter?: ITicketAnalyticsFilter;
334
+ widgets?: ITicketWidgetConfiguration[];
335
+ refreshMode?: TicketWidgetRefreshMode;
336
+ refreshIntervalSeconds?: number;
337
+ isDefault?: boolean;
338
+ }
339
+ export interface IUpdateTicketDashboardDto {
340
+ name?: string;
341
+ description?: string;
342
+ audience?: TicketAnalyticsAudience;
343
+ visibility?: TicketDashboardVisibility;
344
+ sharedRoleIds?: string[];
345
+ sharedGroupIds?: string[];
346
+ defaultFilter?: ITicketAnalyticsFilter;
347
+ widgets?: ITicketWidgetConfiguration[];
348
+ refreshMode?: TicketWidgetRefreshMode;
349
+ refreshIntervalSeconds?: number;
350
+ isDefault?: boolean;
351
+ }
326
352
  export interface ITicketDashboardTemplate {
327
353
  id: string;
328
354
  spaceId: string;
@@ -332,6 +358,20 @@ export interface ITicketDashboardTemplate {
332
358
  widgets: ITicketWidgetConfiguration[];
333
359
  enabled: boolean;
334
360
  }
361
+ export interface ICreateTicketDashboardTemplateDto {
362
+ name: string;
363
+ description?: string;
364
+ audience: TicketAnalyticsAudience;
365
+ widgets?: ITicketWidgetConfiguration[];
366
+ enabled?: boolean;
367
+ }
368
+ export interface IUpdateTicketDashboardTemplateDto {
369
+ name?: string;
370
+ description?: string;
371
+ audience?: TicketAnalyticsAudience;
372
+ widgets?: ITicketWidgetConfiguration[];
373
+ enabled?: boolean;
374
+ }
335
375
  export interface ITicketDashboardSnapshot {
336
376
  id: string;
337
377
  dashboardId: string;
@@ -371,6 +411,26 @@ export interface ITicketAnalyticsGoal {
371
411
  ownerUserId?: string;
372
412
  createdAt: Date;
373
413
  }
414
+ export interface ICreateTicketAnalyticsGoalDto {
415
+ name: string;
416
+ metric: TicketMetricCode;
417
+ target: number;
418
+ filter: ITicketAnalyticsFilter;
419
+ validFrom: Date;
420
+ validUntil?: Date;
421
+ ownerGroupId?: string;
422
+ ownerUserId?: string;
423
+ }
424
+ export interface IUpdateTicketAnalyticsGoalDto {
425
+ name?: string;
426
+ metric?: TicketMetricCode;
427
+ target?: number;
428
+ filter?: ITicketAnalyticsFilter;
429
+ validFrom?: Date;
430
+ validUntil?: Date;
431
+ ownerGroupId?: string;
432
+ ownerUserId?: string;
433
+ }
374
434
  /** Reports freshness so users know whether a card is real-time, delayed or partial. */
375
435
  export interface ITicketAnalyticsFreshness {
376
436
  metric: TicketMetricCode;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trii/types",
3
- "version": "2.10.675",
3
+ "version": "2.10.677",
4
4
  "description": "Types definitions for Trii projects - ",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",