-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Expand file tree
/
Copy pathqueryKeys.ts
More file actions
164 lines (151 loc) · 8.06 KB
/
queryKeys.ts
File metadata and controls
164 lines (151 loc) · 8.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
import type {
ILivechatDepartment,
IMessage,
IRoom,
ITeam,
IUser,
ILivechatAgent,
IOutboundProvider,
RoomType,
} from '@rocket.chat/core-typings';
import type { PaginatedRequest } from '@rocket.chat/rest-typings';
export const roomsQueryKeys = {
all: ['rooms'] as const,
room: (rid: IRoom['_id']) => ['rooms', rid] as const,
roomReference: (reference: string, type: RoomType, uid?: IUser['_id'], username?: IUser['username']) => [
...roomsQueryKeys.all,
reference,
type,
uid ?? username,
],
starredMessages: (rid: IRoom['_id']) => [...roomsQueryKeys.room(rid), 'starred-messages'] as const,
pinnedMessages: (rid: IRoom['_id']) => [...roomsQueryKeys.room(rid), 'pinned-messages'] as const,
messages: (rid: IRoom['_id']) => [...roomsQueryKeys.room(rid), 'messages'] as const,
message: (rid: IRoom['_id'], mid: IMessage['_id']) => [...roomsQueryKeys.messages(rid), mid] as const,
threads: (rid: IRoom['_id']) => [...roomsQueryKeys.room(rid), 'threads'] as const,
roles: (rid: IRoom['_id']) => [...roomsQueryKeys.room(rid), 'roles'] as const,
info: (rid: IRoom['_id']) => [...roomsQueryKeys.room(rid), 'info'] as const,
};
export const subscriptionsQueryKeys = {
all: ['subscriptions'] as const,
subscription: (rid: IRoom['_id']) => [...subscriptionsQueryKeys.all, { rid }] as const,
};
export const cannedResponsesQueryKeys = {
all: ['canned-responses'] as const,
};
export const rolesQueryKeys = {
all: ['roles'] as const,
userRoles: () => [...rolesQueryKeys.all, 'user-roles'] as const,
};
export const omnichannelQueryKeys = {
all: ['omnichannel'] as const,
department: (id: string) => [...omnichannelQueryKeys.all, 'department', id] as const,
agents: (query?: PaginatedRequest) =>
!query ? ([...omnichannelQueryKeys.all, 'agents'] as const) : ([...omnichannelQueryKeys.all, 'agents', query] as const),
agent: (uid: ILivechatAgent['_id']) => [...omnichannelQueryKeys.agents(), uid] as const,
agentDepartments: (uid: ILivechatAgent['_id']) => [...omnichannelQueryKeys.agent(uid), 'departments'] as const,
managers: (query?: PaginatedRequest) =>
!query ? ([...omnichannelQueryKeys.all, 'managers'] as const) : ([...omnichannelQueryKeys.all, 'managers', query] as const),
extensions: (
params:
| {
userId: string;
type: 'free' | 'allocated' | 'available';
}
| {
username: string;
type: 'free' | 'allocated' | 'available';
},
) => [...omnichannelQueryKeys.all, 'extensions', params] as const,
livechat: {
appearance: () => [...omnichannelQueryKeys.all, 'livechat', 'appearance'] as const,
customFields: () => [...omnichannelQueryKeys.all, 'livechat', 'custom-fields'] as const,
customFieldsMetadata: (scope: 'visitor' | 'room') => [...omnichannelQueryKeys.all, 'livechat', 'custom-fields', scope] as const,
},
visitorInfo: (uid: string) => [...omnichannelQueryKeys.all, 'visitor-info', uid] as const,
analytics: {
all: (departmentId: ILivechatDepartment['_id']) => [...omnichannelQueryKeys.all, 'analytics', departmentId] as const,
agentsStatus: (departmentId: ILivechatDepartment['_id']) =>
[...omnichannelQueryKeys.analytics.all(departmentId), 'agents-status'] as const,
timings: (departmentId: ILivechatDepartment['_id'], dateRange: { start: string; end: string }) =>
[...omnichannelQueryKeys.analytics.all(departmentId), 'timings', dateRange] as const,
chats: (departmentId: ILivechatDepartment['_id'], dateRange: { start: string; end: string }) =>
[...omnichannelQueryKeys.analytics.all(departmentId), 'chats', dateRange] as const,
chatsPerAgent: (departmentId: ILivechatDepartment['_id'], dateRange: { start: string; end: string }) =>
[...omnichannelQueryKeys.analytics.all(departmentId), 'chats-per-agent', dateRange] as const,
chatsPerDepartment: (departmentId: ILivechatDepartment['_id'], dateRange: { start: string; end: string }) =>
[...omnichannelQueryKeys.analytics.all(departmentId), 'chats-per-department', dateRange] as const,
agentsProductivityTotals: (departmentId: ILivechatDepartment['_id'], dateRange: { start: string; end: string }) =>
[...omnichannelQueryKeys.analytics.all(departmentId), 'agents-productivity', dateRange] as const,
chatsTotals: (departmentId: ILivechatDepartment['_id'], dateRange: { start: string; end: string }) =>
[...omnichannelQueryKeys.analytics.all(departmentId), 'chats-totals', dateRange] as const,
conversationTotals: (departmentId: ILivechatDepartment['_id'], dateRange: { start: string; end: string }) =>
[...omnichannelQueryKeys.analytics.all(departmentId), 'conversation-totals', dateRange] as const,
productivityTotals: (departmentId: ILivechatDepartment['_id'], dateRange: { start: string; end: string }) =>
[...omnichannelQueryKeys.analytics.all(departmentId), 'productivity-totals', dateRange] as const,
},
contacts: (query?: { filter: string; limit?: number }) =>
!query ? [...omnichannelQueryKeys.all, 'contacts'] : ([...omnichannelQueryKeys.all, 'contacts', query] as const),
contact: (contactId?: string) => [...omnichannelQueryKeys.contacts(), contactId] as const,
outboundProviders: (filter?: { type: IOutboundProvider['providerType'] }) =>
!filter
? ([...omnichannelQueryKeys.all, 'outbound-messaging', 'providers'] as const)
: ([...omnichannelQueryKeys.all, 'outbound-messaging', 'providers', filter] as const),
outboundProviderMetadata: (providerId: string) => [...omnichannelQueryKeys.outboundProviders(), providerId] as const,
};
export const deviceManagementQueryKeys = {
all: ['device-management'] as const,
userSessions: (params: { sort?: string; count?: number; offset?: number }) =>
[...deviceManagementQueryKeys.all, 'users-sessions', params] as const,
sessions: (params: { sort?: string; count?: number; offset?: number }) =>
[...deviceManagementQueryKeys.all, 'all-users-sessions', params] as const,
sessionInfo: (sessionId: string) => [...deviceManagementQueryKeys.all, 'session-info', sessionId] as const,
};
export const miscQueryKeys = {
personalAccessTokens: ['personal-access-tokens'] as const,
lookup: (endpoint: string) => ['lookup', endpoint] as const,
autotranslateSupportedLanguages: (targetLanguage: string) => ['autotranslate', 'supported-languages', targetLanguage] as const,
};
export const voipQueryKeys = {
all: ['voip'] as const,
room: (rid: IRoom['_id'], token: string) => [...voipQueryKeys.all, 'room', rid, token] as const,
};
export const usersQueryKeys = {
all: ['users'] as const,
userInfo: ({ uid, username }: { uid?: IUser['_id']; username?: IUser['username'] }) =>
[...usersQueryKeys.all, 'info', { uid, username }] as const,
};
export const teamsQueryKeys = {
all: ['teams'] as const,
team: (teamId: ITeam['_id']) => [...teamsQueryKeys.all, teamId] as const,
teamInfo: (teamId: ITeam['_id']) => [...teamsQueryKeys.team(teamId), 'info'] as const,
roomsOfUser: (teamId: ITeam['_id'], userId: IUser['_id'], options?: { canUserDelete: boolean }) =>
[...teamsQueryKeys.team(teamId), 'rooms-of-user', userId, options] as const,
listUserTeams: (userId: IUser['_id']) => [...teamsQueryKeys.all, 'listUserTeams', userId] as const,
};
export const appsQueryKeys = {
all: ['apps'] as const,
slashCommands: () => [...appsQueryKeys.all, 'slashCommands'] as const,
};
export const ABACQueryKeys = {
all: ['abac'] as const,
logs: {
all: () => [...ABACQueryKeys.all, 'logs'] as const,
list: (query?: PaginatedRequest) => [...ABACQueryKeys.logs.all(), 'list', query] as const,
},
roomAttributes: {
all: () => [...ABACQueryKeys.all, 'room-attributes'] as const,
list: (query?: PaginatedRequest) => [...ABACQueryKeys.roomAttributes.all(), query] as const,
attribute: (attributeId: string) => [...ABACQueryKeys.roomAttributes.all(), attributeId] as const,
},
rooms: {
all: () => [...ABACQueryKeys.all, 'rooms'] as const,
list: (query?: PaginatedRequest) => [...ABACQueryKeys.rooms.all(), query] as const,
autocomplete: (query?: PaginatedRequest) => [...ABACQueryKeys.rooms.all(), 'autocomplete', query] as const,
room: (roomId: string) => [...ABACQueryKeys.rooms.all(), roomId] as const,
},
};
export const callHistoryQueryKeys = {
all: ['call-history'] as const,
info: (callId?: string) => [...callHistoryQueryKeys.all, 'info', callId] as const,
};