@dereekb/zoho 13.8.0 → 13.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/LICENSE +21 -0
- package/cli/index.js +8 -0
- package/cli/package.json +20 -0
- package/index.cjs.js +2537 -228
- package/index.esm.js +2474 -229
- package/nestjs/index.cjs.js +852 -191
- package/nestjs/index.esm.js +849 -193
- package/nestjs/package.json +5 -5
- package/nestjs/src/lib/desk/desk.api.d.ts +213 -0
- package/nestjs/src/lib/desk/desk.config.d.ts +27 -0
- package/nestjs/src/lib/desk/desk.module.d.ts +62 -0
- package/nestjs/src/lib/desk/index.d.ts +3 -0
- package/nestjs/src/lib/index.d.ts +1 -0
- package/package.json +12 -5
- package/src/lib/desk/desk.agent.d.ts +45 -0
- package/src/lib/desk/desk.api.activities.d.ts +43 -0
- package/src/lib/desk/desk.api.agents.d.ts +91 -0
- package/src/lib/desk/desk.api.attachments.d.ts +47 -0
- package/src/lib/desk/desk.api.comments.d.ts +86 -0
- package/src/lib/desk/desk.api.contacts.d.ts +81 -0
- package/src/lib/desk/desk.api.departments.d.ts +47 -0
- package/src/lib/desk/desk.api.followers.d.ts +57 -0
- package/src/lib/desk/desk.api.page.d.ts +72 -0
- package/src/lib/desk/desk.api.tags.d.ts +102 -0
- package/src/lib/desk/desk.api.threads.d.ts +60 -0
- package/src/lib/desk/desk.api.tickets.d.ts +227 -0
- package/src/lib/desk/desk.api.time.d.ts +109 -0
- package/src/lib/desk/desk.config.d.ts +75 -0
- package/src/lib/desk/desk.contact.d.ts +50 -0
- package/src/lib/desk/desk.d.ts +44 -0
- package/src/lib/desk/desk.department.d.ts +27 -0
- package/src/lib/desk/desk.error.api.d.ts +33 -0
- package/src/lib/desk/desk.factory.d.ts +47 -0
- package/src/lib/desk/desk.limit.d.ts +39 -0
- package/src/lib/desk/desk.ticket.d.ts +308 -0
- package/src/lib/desk/index.d.ts +21 -0
- package/src/lib/index.d.ts +1 -0
- package/src/lib/zoho.limit.d.ts +66 -10
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { type Maybe, type ArrayOrValue } from '@dereekb/util';
|
|
2
|
+
import { type FetchJsonBody, type FetchJsonInput, type FetchPage, type FetchPageFactoryOptions } from '@dereekb/util/fetch';
|
|
3
|
+
import { type ZohoDeskContext } from './desk.config';
|
|
4
|
+
import { type ZohoDeskTicketId, type ZohoDeskContactId, type ZohoDeskProductId, type ZohoDeskDepartmentId, type ZohoDeskAgentId } from './desk';
|
|
5
|
+
import { type ZohoDeskTicket, type ZohoDeskTicketSortBy, type ZohoDeskTicketInclude, type ZohoDeskTicketMetrics, type ZohoDeskTicketPriority, type ZohoDeskTicketChannel, type ZohoDeskAgentTicketCount } from './desk.ticket';
|
|
6
|
+
import { type ZohoDeskPageFilter, type ZohoDeskPageResult } from './desk.api.page';
|
|
7
|
+
/**
|
|
8
|
+
* Constructs the standard FetchJsonInput used by Desk API calls, pairing the HTTP method with an optional body.
|
|
9
|
+
*
|
|
10
|
+
* @param method - HTTP method to use for the request
|
|
11
|
+
* @param body - Optional request body to include
|
|
12
|
+
* @returns Configured fetch input for the Zoho Desk API call
|
|
13
|
+
*/
|
|
14
|
+
export declare function zohoDeskApiFetchJsonInput(method: string, body?: Maybe<FetchJsonBody>): FetchJsonInput;
|
|
15
|
+
/**
|
|
16
|
+
* Input parameters for listing tickets via `GET /tickets`.
|
|
17
|
+
*/
|
|
18
|
+
export interface ZohoDeskGetTicketsInput extends ZohoDeskPageFilter {
|
|
19
|
+
readonly sortBy?: ZohoDeskTicketSortBy;
|
|
20
|
+
readonly include?: ArrayOrValue<ZohoDeskTicketInclude>;
|
|
21
|
+
readonly departmentId?: ZohoDeskDepartmentId;
|
|
22
|
+
readonly departmentIds?: string;
|
|
23
|
+
readonly channel?: ZohoDeskTicketChannel;
|
|
24
|
+
readonly priority?: ZohoDeskTicketPriority;
|
|
25
|
+
readonly receivedInDays?: number;
|
|
26
|
+
readonly viewId?: string;
|
|
27
|
+
readonly assignee?: string;
|
|
28
|
+
readonly fields?: string;
|
|
29
|
+
readonly status?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Response from listing tickets, containing an array of tickets.
|
|
33
|
+
*/
|
|
34
|
+
export type ZohoDeskGetTicketsResponse = ZohoDeskPageResult<ZohoDeskTicket>;
|
|
35
|
+
/**
|
|
36
|
+
* Function that retrieves a paginated list of tickets.
|
|
37
|
+
*/
|
|
38
|
+
export type ZohoDeskGetTicketsFunction = (input: ZohoDeskGetTicketsInput) => Promise<ZohoDeskGetTicketsResponse>;
|
|
39
|
+
/**
|
|
40
|
+
* Creates a {@link ZohoDeskGetTicketsFunction} bound to the given context.
|
|
41
|
+
*
|
|
42
|
+
* Retrieves a paginated list of tickets from Zoho Desk, with optional filtering by
|
|
43
|
+
* department, status, priority, channel, assignee, and view.
|
|
44
|
+
*
|
|
45
|
+
* @param context - Authenticated Zoho Desk context
|
|
46
|
+
* @returns Function that retrieves paginated tickets
|
|
47
|
+
*/
|
|
48
|
+
export declare function zohoDeskGetTickets(context: ZohoDeskContext): ZohoDeskGetTicketsFunction;
|
|
49
|
+
/**
|
|
50
|
+
* Input parameters for retrieving a single ticket via `GET /tickets/{ticketId}`.
|
|
51
|
+
*/
|
|
52
|
+
export interface ZohoDeskGetTicketByIdInput {
|
|
53
|
+
readonly ticketId: ZohoDeskTicketId;
|
|
54
|
+
readonly include?: ArrayOrValue<ZohoDeskTicketInclude>;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Function that retrieves a single ticket by ID.
|
|
58
|
+
*/
|
|
59
|
+
export type ZohoDeskGetTicketByIdFunction = (input: ZohoDeskGetTicketByIdInput) => Promise<ZohoDeskTicket>;
|
|
60
|
+
/**
|
|
61
|
+
* Creates a {@link ZohoDeskGetTicketByIdFunction} bound to the given context.
|
|
62
|
+
*
|
|
63
|
+
* Retrieves a single ticket by its ID, with optional inline expansion of related entities.
|
|
64
|
+
*
|
|
65
|
+
* @param context - Authenticated Zoho Desk context
|
|
66
|
+
* @returns Function that retrieves a single ticket
|
|
67
|
+
*/
|
|
68
|
+
export declare function zohoDeskGetTicketById(context: ZohoDeskContext): ZohoDeskGetTicketByIdFunction;
|
|
69
|
+
/**
|
|
70
|
+
* Input parameters for searching tickets via `GET /tickets/search`.
|
|
71
|
+
*/
|
|
72
|
+
export interface ZohoDeskSearchTicketsInput extends ZohoDeskPageFilter {
|
|
73
|
+
readonly sortBy?: ZohoDeskTicketSortBy;
|
|
74
|
+
readonly ticketNumber?: string;
|
|
75
|
+
readonly subject?: string;
|
|
76
|
+
readonly departmentId?: ZohoDeskDepartmentId;
|
|
77
|
+
readonly channel?: string;
|
|
78
|
+
readonly customerResponseTimeRange?: string;
|
|
79
|
+
readonly description?: string;
|
|
80
|
+
readonly productName?: string;
|
|
81
|
+
readonly all?: string;
|
|
82
|
+
readonly dueDateRange?: string;
|
|
83
|
+
readonly id?: ZohoDeskTicketId;
|
|
84
|
+
readonly tag?: string;
|
|
85
|
+
readonly email?: string;
|
|
86
|
+
readonly productId?: ZohoDeskProductId;
|
|
87
|
+
readonly contactId?: ZohoDeskContactId;
|
|
88
|
+
readonly contactName?: string;
|
|
89
|
+
readonly createdTimeRange?: string;
|
|
90
|
+
readonly priority?: ZohoDeskTicketPriority;
|
|
91
|
+
readonly assigneeId?: ZohoDeskAgentId;
|
|
92
|
+
readonly accountId?: string;
|
|
93
|
+
readonly phone?: string;
|
|
94
|
+
readonly modifiedTimeRange?: string;
|
|
95
|
+
readonly category?: string;
|
|
96
|
+
readonly status?: string;
|
|
97
|
+
readonly customField1?: string;
|
|
98
|
+
readonly customField2?: string;
|
|
99
|
+
readonly customField3?: string;
|
|
100
|
+
readonly customField4?: string;
|
|
101
|
+
readonly customField5?: string;
|
|
102
|
+
readonly customField6?: string;
|
|
103
|
+
readonly customField7?: string;
|
|
104
|
+
readonly customField8?: string;
|
|
105
|
+
readonly customField9?: string;
|
|
106
|
+
readonly customField10?: string;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Response from searching tickets.
|
|
110
|
+
*/
|
|
111
|
+
export type ZohoDeskSearchTicketsResponse = ZohoDeskPageResult<ZohoDeskTicket>;
|
|
112
|
+
/**
|
|
113
|
+
* Function that searches for tickets.
|
|
114
|
+
*/
|
|
115
|
+
export type ZohoDeskSearchTicketsFunction = (input: ZohoDeskSearchTicketsInput) => Promise<ZohoDeskSearchTicketsResponse>;
|
|
116
|
+
/**
|
|
117
|
+
* Creates a {@link ZohoDeskSearchTicketsFunction} bound to the given context.
|
|
118
|
+
*
|
|
119
|
+
* Searches for tickets matching the given filter criteria. Supports filtering by
|
|
120
|
+
* many fields including subject, email, status, priority, date ranges, and custom fields.
|
|
121
|
+
*
|
|
122
|
+
* @param context - Authenticated Zoho Desk context
|
|
123
|
+
* @returns Function that searches for tickets
|
|
124
|
+
*/
|
|
125
|
+
export declare function zohoDeskSearchTickets(context: ZohoDeskContext): ZohoDeskSearchTicketsFunction;
|
|
126
|
+
/**
|
|
127
|
+
* Input parameters for listing tickets for a specific contact via `GET /contacts/{contactId}/tickets`.
|
|
128
|
+
*/
|
|
129
|
+
export interface ZohoDeskGetTicketsForContactInput extends ZohoDeskPageFilter {
|
|
130
|
+
readonly contactId: ZohoDeskContactId;
|
|
131
|
+
readonly sortBy?: ZohoDeskTicketSortBy;
|
|
132
|
+
readonly include?: ArrayOrValue<ZohoDeskTicketInclude>;
|
|
133
|
+
readonly departmentId?: ZohoDeskDepartmentId;
|
|
134
|
+
readonly status?: string;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Function that retrieves tickets for a specific contact.
|
|
138
|
+
*/
|
|
139
|
+
export type ZohoDeskGetTicketsForContactFunction = (input: ZohoDeskGetTicketsForContactInput) => Promise<ZohoDeskPageResult<ZohoDeskTicket>>;
|
|
140
|
+
/**
|
|
141
|
+
* Creates a {@link ZohoDeskGetTicketsForContactFunction} bound to the given context.
|
|
142
|
+
*
|
|
143
|
+
* @param context - Authenticated Zoho Desk context
|
|
144
|
+
* @returns Function that retrieves tickets for a contact
|
|
145
|
+
*/
|
|
146
|
+
export declare function zohoDeskGetTicketsForContact(context: ZohoDeskContext): ZohoDeskGetTicketsForContactFunction;
|
|
147
|
+
/**
|
|
148
|
+
* Input parameters for listing tickets for a specific product via `GET /products/{productId}/tickets`.
|
|
149
|
+
*/
|
|
150
|
+
export interface ZohoDeskGetTicketsForProductInput extends ZohoDeskPageFilter {
|
|
151
|
+
readonly productId: ZohoDeskProductId;
|
|
152
|
+
readonly sortBy?: ZohoDeskTicketSortBy;
|
|
153
|
+
readonly include?: ArrayOrValue<ZohoDeskTicketInclude>;
|
|
154
|
+
readonly departmentId?: ZohoDeskDepartmentId;
|
|
155
|
+
readonly status?: string;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Function that retrieves tickets for a specific product.
|
|
159
|
+
*/
|
|
160
|
+
export type ZohoDeskGetTicketsForProductFunction = (input: ZohoDeskGetTicketsForProductInput) => Promise<ZohoDeskPageResult<ZohoDeskTicket>>;
|
|
161
|
+
/**
|
|
162
|
+
* Creates a {@link ZohoDeskGetTicketsForProductFunction} bound to the given context.
|
|
163
|
+
*
|
|
164
|
+
* @param context - Authenticated Zoho Desk context
|
|
165
|
+
* @returns Function that retrieves tickets for a product
|
|
166
|
+
*/
|
|
167
|
+
export declare function zohoDeskGetTicketsForProduct(context: ZohoDeskContext): ZohoDeskGetTicketsForProductFunction;
|
|
168
|
+
/**
|
|
169
|
+
* Input parameters for retrieving ticket metrics via `GET /tickets/{ticketId}/metrics`.
|
|
170
|
+
*/
|
|
171
|
+
export interface ZohoDeskGetTicketMetricsInput {
|
|
172
|
+
readonly ticketId: ZohoDeskTicketId;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Function that retrieves metrics for a specific ticket.
|
|
176
|
+
*/
|
|
177
|
+
export type ZohoDeskGetTicketMetricsFunction = (input: ZohoDeskGetTicketMetricsInput) => Promise<ZohoDeskTicketMetrics>;
|
|
178
|
+
/**
|
|
179
|
+
* Creates a {@link ZohoDeskGetTicketMetricsFunction} bound to the given context.
|
|
180
|
+
*
|
|
181
|
+
* @param context - Authenticated Zoho Desk context
|
|
182
|
+
* @returns Function that retrieves ticket metrics
|
|
183
|
+
*/
|
|
184
|
+
export declare function zohoDeskGetTicketMetrics(context: ZohoDeskContext): ZohoDeskGetTicketMetricsFunction;
|
|
185
|
+
/**
|
|
186
|
+
* Input parameters for retrieving agent ticket counts via `GET /agentsTicketsCount`.
|
|
187
|
+
*/
|
|
188
|
+
export interface ZohoDeskGetAgentsTicketsCountInput {
|
|
189
|
+
readonly agentIds: ArrayOrValue<ZohoDeskAgentId>;
|
|
190
|
+
readonly departmentId?: ZohoDeskDepartmentId;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Function that retrieves ticket counts per agent.
|
|
194
|
+
*/
|
|
195
|
+
export type ZohoDeskGetAgentsTicketsCountFunction = (input: ZohoDeskGetAgentsTicketsCountInput) => Promise<ZohoDeskAgentTicketCount[]>;
|
|
196
|
+
/**
|
|
197
|
+
* Creates a {@link ZohoDeskGetAgentsTicketsCountFunction} bound to the given context.
|
|
198
|
+
*
|
|
199
|
+
* @param context - Authenticated Zoho Desk context
|
|
200
|
+
* @returns Function that retrieves agent ticket counts
|
|
201
|
+
*/
|
|
202
|
+
export declare function zohoDeskGetAgentsTicketsCount(context: ZohoDeskContext): ZohoDeskGetAgentsTicketsCountFunction;
|
|
203
|
+
/**
|
|
204
|
+
* Factory that creates paginated iterators for ticket list queries.
|
|
205
|
+
*/
|
|
206
|
+
export type ZohoDeskGetTicketsPageFactory = (input: ZohoDeskGetTicketsInput, options?: Maybe<FetchPageFactoryOptions<ZohoDeskGetTicketsInput, ZohoDeskGetTicketsResponse>>) => FetchPage<ZohoDeskGetTicketsInput, ZohoDeskGetTicketsResponse>;
|
|
207
|
+
/**
|
|
208
|
+
* Creates a {@link ZohoDeskGetTicketsPageFactory} bound to the given context.
|
|
209
|
+
*
|
|
210
|
+
* Returns a page factory that automatically handles Zoho Desk's offset-based pagination,
|
|
211
|
+
* making it easy to iterate through all tickets across multiple pages.
|
|
212
|
+
*
|
|
213
|
+
* @param context - Authenticated Zoho Desk context
|
|
214
|
+
* @returns Page factory for iterating over ticket results
|
|
215
|
+
*/
|
|
216
|
+
export declare function zohoDeskGetTicketsPageFactory(context: ZohoDeskContext): ZohoDeskGetTicketsPageFactory;
|
|
217
|
+
/**
|
|
218
|
+
* Factory that creates paginated iterators for ticket search queries.
|
|
219
|
+
*/
|
|
220
|
+
export type ZohoDeskSearchTicketsPageFactory = (input: ZohoDeskSearchTicketsInput, options?: Maybe<FetchPageFactoryOptions<ZohoDeskSearchTicketsInput, ZohoDeskSearchTicketsResponse>>) => FetchPage<ZohoDeskSearchTicketsInput, ZohoDeskSearchTicketsResponse>;
|
|
221
|
+
/**
|
|
222
|
+
* Creates a {@link ZohoDeskSearchTicketsPageFactory} bound to the given context.
|
|
223
|
+
*
|
|
224
|
+
* @param context - Authenticated Zoho Desk context
|
|
225
|
+
* @returns Page factory for iterating over search results
|
|
226
|
+
*/
|
|
227
|
+
export declare function zohoDeskSearchTicketsPageFactory(context: ZohoDeskContext): ZohoDeskSearchTicketsPageFactory;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { type Maybe } from '@dereekb/util';
|
|
2
|
+
import { type ZohoDeskContext } from './desk.config';
|
|
3
|
+
import { type ZohoDeskTicketId } from './desk';
|
|
4
|
+
import { type ZohoDeskTicketTimeEntry, type ZohoDeskTicketTimer } from './desk.ticket';
|
|
5
|
+
import { type ZohoDeskPageFilter, type ZohoDeskPageResult } from './desk.api.page';
|
|
6
|
+
/**
|
|
7
|
+
* Input parameters for retrieving the timer state for a ticket via `GET /tickets/{ticketId}/timer`.
|
|
8
|
+
*/
|
|
9
|
+
export interface ZohoDeskGetTicketTimerInput {
|
|
10
|
+
readonly ticketId: ZohoDeskTicketId;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Function that retrieves the timer state for a ticket.
|
|
14
|
+
*/
|
|
15
|
+
export type ZohoDeskGetTicketTimerFunction = (input: ZohoDeskGetTicketTimerInput) => Promise<ZohoDeskTicketTimer>;
|
|
16
|
+
/**
|
|
17
|
+
* Creates a {@link ZohoDeskGetTicketTimerFunction} bound to the given context.
|
|
18
|
+
*
|
|
19
|
+
* @param context - Authenticated Zoho Desk context
|
|
20
|
+
* @returns Function that retrieves the ticket timer
|
|
21
|
+
*/
|
|
22
|
+
export declare function zohoDeskGetTicketTimer(context: ZohoDeskContext): ZohoDeskGetTicketTimerFunction;
|
|
23
|
+
/**
|
|
24
|
+
* Timer action to perform on a ticket.
|
|
25
|
+
*/
|
|
26
|
+
export type ZohoDeskTimerAction = 'start' | 'pause' | 'resume' | 'stop';
|
|
27
|
+
/**
|
|
28
|
+
* Input parameters for performing a timer action on a ticket via `POST /tickets/{ticketId}/timer`.
|
|
29
|
+
*/
|
|
30
|
+
export interface ZohoDeskPerformTicketTimerActionInput {
|
|
31
|
+
readonly ticketId: ZohoDeskTicketId;
|
|
32
|
+
readonly timerAction: ZohoDeskTimerAction;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Function that performs a timer action on a ticket.
|
|
36
|
+
*/
|
|
37
|
+
export type ZohoDeskPerformTicketTimerActionFunction = (input: ZohoDeskPerformTicketTimerActionInput) => Promise<ZohoDeskTicketTimer>;
|
|
38
|
+
/**
|
|
39
|
+
* Creates a {@link ZohoDeskPerformTicketTimerActionFunction} bound to the given context.
|
|
40
|
+
*
|
|
41
|
+
* @param context - Authenticated Zoho Desk context
|
|
42
|
+
* @returns Function that performs a timer action on a ticket
|
|
43
|
+
*/
|
|
44
|
+
export declare function zohoDeskPerformTicketTimerAction(context: ZohoDeskContext): ZohoDeskPerformTicketTimerActionFunction;
|
|
45
|
+
/**
|
|
46
|
+
* Input parameters for listing time entries for a ticket via `GET /tickets/{ticketId}/timeEntries`.
|
|
47
|
+
*/
|
|
48
|
+
export interface ZohoDeskGetTicketTimeEntriesInput extends ZohoDeskPageFilter {
|
|
49
|
+
readonly ticketId: ZohoDeskTicketId;
|
|
50
|
+
readonly billingType?: string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Response from listing ticket time entries.
|
|
54
|
+
*/
|
|
55
|
+
export type ZohoDeskGetTicketTimeEntriesResponse = ZohoDeskPageResult<ZohoDeskTicketTimeEntry>;
|
|
56
|
+
/**
|
|
57
|
+
* Function that retrieves time entries for a specific ticket.
|
|
58
|
+
*/
|
|
59
|
+
export type ZohoDeskGetTicketTimeEntriesFunction = (input: ZohoDeskGetTicketTimeEntriesInput) => Promise<ZohoDeskGetTicketTimeEntriesResponse>;
|
|
60
|
+
/**
|
|
61
|
+
* Creates a {@link ZohoDeskGetTicketTimeEntriesFunction} bound to the given context.
|
|
62
|
+
*
|
|
63
|
+
* @param context - Authenticated Zoho Desk context
|
|
64
|
+
* @returns Function that retrieves time entries for a ticket
|
|
65
|
+
*/
|
|
66
|
+
export declare function zohoDeskGetTicketTimeEntries(context: ZohoDeskContext): ZohoDeskGetTicketTimeEntriesFunction;
|
|
67
|
+
/**
|
|
68
|
+
* Input parameters for retrieving a single time entry via `GET /tickets/{ticketId}/timeEntries/{timeEntryId}`.
|
|
69
|
+
*/
|
|
70
|
+
export interface ZohoDeskGetTicketTimeEntryByIdInput {
|
|
71
|
+
readonly ticketId: ZohoDeskTicketId;
|
|
72
|
+
readonly timeEntryId: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Function that retrieves a single time entry by ID.
|
|
76
|
+
*/
|
|
77
|
+
export type ZohoDeskGetTicketTimeEntryByIdFunction = (input: ZohoDeskGetTicketTimeEntryByIdInput) => Promise<ZohoDeskTicketTimeEntry>;
|
|
78
|
+
/**
|
|
79
|
+
* Creates a {@link ZohoDeskGetTicketTimeEntryByIdFunction} bound to the given context.
|
|
80
|
+
*
|
|
81
|
+
* @param context - Authenticated Zoho Desk context
|
|
82
|
+
* @returns Function that retrieves a single time entry
|
|
83
|
+
*/
|
|
84
|
+
export declare function zohoDeskGetTicketTimeEntryById(context: ZohoDeskContext): ZohoDeskGetTicketTimeEntryByIdFunction;
|
|
85
|
+
/**
|
|
86
|
+
* Input parameters for getting the summation of time entries via `GET /tickets/{ticketId}/timeEntries/summation`.
|
|
87
|
+
*/
|
|
88
|
+
export interface ZohoDeskGetTicketTimeEntrySummationInput {
|
|
89
|
+
readonly ticketId: ZohoDeskTicketId;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Summation of time entries for a ticket.
|
|
93
|
+
*/
|
|
94
|
+
export interface ZohoDeskTicketTimeEntrySummation {
|
|
95
|
+
readonly totalHours?: Maybe<string>;
|
|
96
|
+
readonly totalMinutes?: Maybe<string>;
|
|
97
|
+
readonly totalCost?: Maybe<string>;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Function that retrieves the summation of time entries for a ticket.
|
|
101
|
+
*/
|
|
102
|
+
export type ZohoDeskGetTicketTimeEntrySummationFunction = (input: ZohoDeskGetTicketTimeEntrySummationInput) => Promise<ZohoDeskTicketTimeEntrySummation>;
|
|
103
|
+
/**
|
|
104
|
+
* Creates a {@link ZohoDeskGetTicketTimeEntrySummationFunction} bound to the given context.
|
|
105
|
+
*
|
|
106
|
+
* @param context - Authenticated Zoho Desk context
|
|
107
|
+
* @returns Function that retrieves time entry summation
|
|
108
|
+
*/
|
|
109
|
+
export declare function zohoDeskGetTicketTimeEntrySummation(context: ZohoDeskContext): ZohoDeskGetTicketTimeEntrySummationFunction;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { type FactoryWithRequiredInput } from '@dereekb/util';
|
|
2
|
+
import { type ConfiguredFetch, type FetchJsonFunction } from '@dereekb/util/fetch';
|
|
3
|
+
import { type ZohoApiUrl, type ZohoApiUrlKey, type ZohoConfig, type ZohoApiServiceName } from '../zoho.config';
|
|
4
|
+
import { type ZohoAccessTokenStringFactory, type ZohoServiceAccessTokenKey } from '../accounts';
|
|
5
|
+
import { type ZohoRateLimiterRef } from '../zoho.limit';
|
|
6
|
+
import { type ZohoDeskOrgId } from './desk';
|
|
7
|
+
/**
|
|
8
|
+
* Service identifier used for Zoho Desk API access token resolution and service routing.
|
|
9
|
+
*/
|
|
10
|
+
export declare const ZOHO_DESK_SERVICE_NAME: ZohoApiServiceName | ZohoServiceAccessTokenKey;
|
|
11
|
+
/**
|
|
12
|
+
* Full base URL for the Zoho Desk API.
|
|
13
|
+
*/
|
|
14
|
+
export type ZohoDeskApiUrl = ZohoApiUrl;
|
|
15
|
+
/**
|
|
16
|
+
* Well-known environment key for selecting a Zoho Desk API endpoint.
|
|
17
|
+
*
|
|
18
|
+
* Zoho Desk does not have a documented sandbox environment, so only 'production' is a known key.
|
|
19
|
+
* Custom URLs (including regional variants like desk.zoho.eu) can be passed directly.
|
|
20
|
+
*/
|
|
21
|
+
export type ZohoDeskApiUrlKey = ZohoApiUrlKey;
|
|
22
|
+
/**
|
|
23
|
+
* Accepts either a well-known environment key or a custom full URL, allowing callers to target
|
|
24
|
+
* production or an arbitrary Desk endpoint (e.g., regional variants).
|
|
25
|
+
*/
|
|
26
|
+
export type ZohoDeskConfigApiUrlInput = ZohoDeskApiUrlKey | ZohoDeskApiUrl;
|
|
27
|
+
/**
|
|
28
|
+
* Resolves a Desk API URL input to its full base URL. The 'production' key maps to the
|
|
29
|
+
* primary Zoho Desk endpoint; custom URLs pass through unchanged.
|
|
30
|
+
*
|
|
31
|
+
* @param input - A well-known environment key or a custom Desk API URL
|
|
32
|
+
* @returns The resolved full Zoho Desk API base URL
|
|
33
|
+
*/
|
|
34
|
+
export declare function zohoDeskConfigApiUrl(input: ZohoDeskConfigApiUrlInput): ZohoApiUrl;
|
|
35
|
+
/**
|
|
36
|
+
* Configuration for a Zoho Desk service instance, including the target API URL and organization ID.
|
|
37
|
+
*
|
|
38
|
+
* Unlike other Zoho services (CRM, Recruit, Sign), the Desk API requires an `orgId` header
|
|
39
|
+
* on all requests.
|
|
40
|
+
*/
|
|
41
|
+
export interface ZohoDeskConfig extends ZohoConfig {
|
|
42
|
+
/**
|
|
43
|
+
* Organization ID required by all Zoho Desk API calls.
|
|
44
|
+
* Obtained from the Zoho Desk organization settings.
|
|
45
|
+
*/
|
|
46
|
+
readonly orgId: ZohoDeskOrgId;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Input provided to a Desk fetch factory to construct an authenticated fetch instance for a specific API base URL.
|
|
50
|
+
*/
|
|
51
|
+
export interface ZohoDeskFetchFactoryParams {
|
|
52
|
+
readonly apiUrl: ZohoDeskApiUrl;
|
|
53
|
+
readonly orgId: ZohoDeskOrgId;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Factory that produces a pre-configured fetch instance bound to a specific Zoho Desk API URL and organization.
|
|
57
|
+
*/
|
|
58
|
+
export type ZohoDeskFetchFactory = FactoryWithRequiredInput<ConfiguredFetch, ZohoDeskFetchFactoryParams>;
|
|
59
|
+
/**
|
|
60
|
+
* Core context for making authenticated Zoho Desk API calls. Bundles the configured fetch,
|
|
61
|
+
* JSON parsing, access token management, rate limiting, and service configuration needed
|
|
62
|
+
* by all Desk operations.
|
|
63
|
+
*/
|
|
64
|
+
export interface ZohoDeskContext extends ZohoRateLimiterRef {
|
|
65
|
+
readonly fetch: ConfiguredFetch;
|
|
66
|
+
readonly fetchJson: FetchJsonFunction;
|
|
67
|
+
readonly accessTokenStringFactory: ZohoAccessTokenStringFactory;
|
|
68
|
+
readonly config: ZohoDeskConfig;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Reference wrapper providing access to a {@link ZohoDeskContext}. Used for dependency injection across Desk service consumers.
|
|
72
|
+
*/
|
|
73
|
+
export interface ZohoDeskContextRef {
|
|
74
|
+
readonly deskContext: ZohoDeskContext;
|
|
75
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type Maybe } from '@dereekb/util';
|
|
2
|
+
import { type ZohoDateTimeString } from '../zoho.type';
|
|
3
|
+
import { type ZohoDeskContactId, type ZohoDeskAccountId } from './desk';
|
|
4
|
+
/**
|
|
5
|
+
* Fields by which Zoho Desk contact lists can be sorted.
|
|
6
|
+
*/
|
|
7
|
+
export type ZohoDeskContactSortBy = 'firstName' | 'lastName' | 'modifiedTime' | 'phone' | 'createdTime' | 'email' | 'account';
|
|
8
|
+
/**
|
|
9
|
+
* Related entities that can be expanded inline when fetching Zoho Desk contacts via the `include` query parameter.
|
|
10
|
+
*/
|
|
11
|
+
export type ZohoDeskContactInclude = 'owner' | 'accounts';
|
|
12
|
+
/**
|
|
13
|
+
* A contact in Zoho Desk.
|
|
14
|
+
*
|
|
15
|
+
* Contacts represent end users or customers who submit support tickets.
|
|
16
|
+
*/
|
|
17
|
+
export interface ZohoDeskContact {
|
|
18
|
+
readonly id: ZohoDeskContactId;
|
|
19
|
+
readonly firstName?: Maybe<string>;
|
|
20
|
+
readonly lastName: string;
|
|
21
|
+
readonly email?: Maybe<string>;
|
|
22
|
+
readonly secondaryEmail?: Maybe<string>;
|
|
23
|
+
readonly phone?: Maybe<string>;
|
|
24
|
+
readonly mobile?: Maybe<string>;
|
|
25
|
+
readonly twitter?: Maybe<string>;
|
|
26
|
+
readonly facebook?: Maybe<string>;
|
|
27
|
+
readonly type?: Maybe<string>;
|
|
28
|
+
readonly title?: Maybe<string>;
|
|
29
|
+
readonly description?: Maybe<string>;
|
|
30
|
+
readonly photoURL?: Maybe<string>;
|
|
31
|
+
readonly webUrl?: Maybe<string>;
|
|
32
|
+
readonly accountId?: Maybe<ZohoDeskAccountId>;
|
|
33
|
+
readonly ownerId?: Maybe<string>;
|
|
34
|
+
readonly country?: Maybe<string>;
|
|
35
|
+
readonly state?: Maybe<string>;
|
|
36
|
+
readonly city?: Maybe<string>;
|
|
37
|
+
readonly street?: Maybe<string>;
|
|
38
|
+
readonly zip?: Maybe<string>;
|
|
39
|
+
readonly isDeleted?: Maybe<boolean>;
|
|
40
|
+
readonly isTrashed?: Maybe<boolean>;
|
|
41
|
+
readonly isEndUser?: Maybe<boolean>;
|
|
42
|
+
readonly isFollowing?: Maybe<boolean>;
|
|
43
|
+
readonly isAnonymous?: Maybe<boolean>;
|
|
44
|
+
readonly isSpam?: Maybe<boolean>;
|
|
45
|
+
readonly createdTime?: Maybe<ZohoDateTimeString>;
|
|
46
|
+
readonly modifiedTime?: Maybe<ZohoDateTimeString>;
|
|
47
|
+
readonly owner?: Maybe<Record<string, unknown>>;
|
|
48
|
+
readonly account?: Maybe<Record<string, unknown>>;
|
|
49
|
+
readonly cf?: Maybe<Record<string, unknown>>;
|
|
50
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identifier of a Zoho Desk organization.
|
|
3
|
+
*/
|
|
4
|
+
export type ZohoDeskOrgId = string;
|
|
5
|
+
/**
|
|
6
|
+
* Generic identifier in Zoho Desk.
|
|
7
|
+
*/
|
|
8
|
+
export type ZohoDeskId = string;
|
|
9
|
+
/**
|
|
10
|
+
* Identifier of a ticket in Zoho Desk.
|
|
11
|
+
*/
|
|
12
|
+
export type ZohoDeskTicketId = string;
|
|
13
|
+
/**
|
|
14
|
+
* Identifier of a contact in Zoho Desk.
|
|
15
|
+
*/
|
|
16
|
+
export type ZohoDeskContactId = string;
|
|
17
|
+
/**
|
|
18
|
+
* Identifier of a product in Zoho Desk.
|
|
19
|
+
*/
|
|
20
|
+
export type ZohoDeskProductId = string;
|
|
21
|
+
/**
|
|
22
|
+
* Identifier of a department in Zoho Desk.
|
|
23
|
+
*/
|
|
24
|
+
export type ZohoDeskDepartmentId = string;
|
|
25
|
+
/**
|
|
26
|
+
* Identifier of an agent in Zoho Desk.
|
|
27
|
+
*/
|
|
28
|
+
export type ZohoDeskAgentId = string;
|
|
29
|
+
/**
|
|
30
|
+
* Identifier of a team in Zoho Desk.
|
|
31
|
+
*/
|
|
32
|
+
export type ZohoDeskTeamId = string;
|
|
33
|
+
/**
|
|
34
|
+
* Identifier of an account in Zoho Desk.
|
|
35
|
+
*/
|
|
36
|
+
export type ZohoDeskAccountId = string;
|
|
37
|
+
/**
|
|
38
|
+
* Identifier of a contract in Zoho Desk.
|
|
39
|
+
*/
|
|
40
|
+
export type ZohoDeskContractId = string;
|
|
41
|
+
/**
|
|
42
|
+
* Sort direction for Zoho Desk list queries.
|
|
43
|
+
*/
|
|
44
|
+
export type ZohoDeskSortOrder = 'asc' | 'desc';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type Maybe } from '@dereekb/util';
|
|
2
|
+
import { type ZohoDateTimeString } from '../zoho.type';
|
|
3
|
+
import { type ZohoDeskDepartmentId } from './desk';
|
|
4
|
+
/**
|
|
5
|
+
* Availability status of the live chat feature for a Zoho Desk department.
|
|
6
|
+
*/
|
|
7
|
+
export type ZohoDeskDepartmentChatStatus = 'AVAILABLE' | 'DISABLED' | 'NOT_CREATED';
|
|
8
|
+
/**
|
|
9
|
+
* A department in Zoho Desk.
|
|
10
|
+
*
|
|
11
|
+
* Departments are organizational units that group tickets by functional area.
|
|
12
|
+
*/
|
|
13
|
+
export interface ZohoDeskDepartment {
|
|
14
|
+
readonly id: ZohoDeskDepartmentId;
|
|
15
|
+
readonly name: string;
|
|
16
|
+
readonly description?: Maybe<string>;
|
|
17
|
+
readonly isEnabled?: Maybe<boolean>;
|
|
18
|
+
readonly isDefault?: Maybe<boolean>;
|
|
19
|
+
readonly hasLogo?: Maybe<boolean>;
|
|
20
|
+
readonly chatStatus?: Maybe<ZohoDeskDepartmentChatStatus>;
|
|
21
|
+
readonly isVisibleInCustomerPortal?: Maybe<boolean>;
|
|
22
|
+
readonly nameInCustomerPortal?: Maybe<string>;
|
|
23
|
+
readonly isAssignToTeamEnabled?: Maybe<boolean>;
|
|
24
|
+
readonly creatorId?: Maybe<string>;
|
|
25
|
+
readonly createdTime?: Maybe<ZohoDateTimeString>;
|
|
26
|
+
readonly associatedAgentIds?: Maybe<string[]>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type FetchResponseError } from '@dereekb/util/fetch';
|
|
2
|
+
import { type ZohoServerErrorResponseData, type ZohoServerErrorResponseDataArrayRef, type ParsedZohoServerError } from '../zoho.error.api';
|
|
3
|
+
/**
|
|
4
|
+
* Pre-configured console logger for Zoho Desk server errors.
|
|
5
|
+
* Data array errors are suppressed since they are handled separately.
|
|
6
|
+
*/
|
|
7
|
+
export declare const logZohoDeskErrorToConsole: import("..").LogZohoServerErrorFunction;
|
|
8
|
+
/**
|
|
9
|
+
* Parses a fetch response error into a typed Zoho Desk server error by extracting and interpreting the JSON error body.
|
|
10
|
+
*
|
|
11
|
+
* @param responseError - The fetch response error to parse
|
|
12
|
+
* @returns The parsed Zoho server error, or undefined if the response could not be parsed
|
|
13
|
+
*/
|
|
14
|
+
export declare function parseZohoDeskError(responseError: FetchResponseError): Promise<ParsedZohoServerError>;
|
|
15
|
+
/**
|
|
16
|
+
* Parses a Zoho Desk error response body into a typed error. Delegates to Desk-specific
|
|
17
|
+
* error code handling before falling back to the generic Zoho error parser.
|
|
18
|
+
*
|
|
19
|
+
* @param errorResponseData - The raw error response data from the Zoho Desk API
|
|
20
|
+
* @param responseError - The original fetch response error for context
|
|
21
|
+
* @returns The parsed Zoho server error, or undefined if the error could not be classified
|
|
22
|
+
*/
|
|
23
|
+
export declare function parseZohoDeskServerErrorResponseData(errorResponseData: ZohoServerErrorResponseData | ZohoServerErrorResponseDataArrayRef, responseError: FetchResponseError): ParsedZohoServerError;
|
|
24
|
+
/**
|
|
25
|
+
* Fetch response interceptor that detects Zoho Desk error payloads hidden within HTTP 200 responses
|
|
26
|
+
* and converts them into proper errors.
|
|
27
|
+
*/
|
|
28
|
+
export declare const interceptZohoDesk200StatusWithErrorResponse: import("@dereekb/util/fetch").FetchJsonInterceptJsonResponseFunction;
|
|
29
|
+
/**
|
|
30
|
+
* Wraps a fetch function with Zoho Desk error parsing and console logging,
|
|
31
|
+
* ensuring all Desk API errors are surfaced as typed exceptions.
|
|
32
|
+
*/
|
|
33
|
+
export declare const handleZohoDeskErrorFetch: import("..").HandleZohoErrorFetchFactory;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type ZohoDeskConfig, type ZohoDeskContextRef, type ZohoDeskFetchFactory } from './desk.config';
|
|
2
|
+
import { type LogZohoServerErrorFunction } from '../zoho.error.api';
|
|
3
|
+
import { type ZohoAccountsContextRef } from '../accounts/accounts.config';
|
|
4
|
+
import { type ZohoRateLimitedFetchHandlerConfig } from '../zoho.limit';
|
|
5
|
+
import { type Maybe } from '@dereekb/util';
|
|
6
|
+
/**
|
|
7
|
+
* Top-level Zoho Desk client instance, providing access to the authenticated {@link ZohoDeskContext}.
|
|
8
|
+
*/
|
|
9
|
+
export type ZohoDesk = ZohoDeskContextRef;
|
|
10
|
+
/**
|
|
11
|
+
* Configuration for creating a {@link ZohoDeskFactory}, combining account credentials
|
|
12
|
+
* with optional overrides for rate limiting, fetch behavior, and error logging.
|
|
13
|
+
*/
|
|
14
|
+
export interface ZohoDeskFactoryConfig extends ZohoAccountsContextRef {
|
|
15
|
+
/**
|
|
16
|
+
* Custom rate limiter configuration to control request concurrency and throttling.
|
|
17
|
+
*/
|
|
18
|
+
readonly rateLimiterConfig?: Maybe<ZohoRateLimitedFetchHandlerConfig>;
|
|
19
|
+
/**
|
|
20
|
+
* Custom fetch factory for creating the underlying HTTP client.
|
|
21
|
+
* Defaults to a standard fetch service with OAuth Bearer token and orgId headers and a 20-second timeout.
|
|
22
|
+
*/
|
|
23
|
+
readonly fetchFactory?: ZohoDeskFetchFactory;
|
|
24
|
+
/**
|
|
25
|
+
* Custom error logging function invoked when Zoho API errors are encountered.
|
|
26
|
+
*/
|
|
27
|
+
readonly logZohoServerErrorFunction?: LogZohoServerErrorFunction;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Factory function that creates a {@link ZohoDesk} client from a {@link ZohoDeskConfig}.
|
|
31
|
+
*/
|
|
32
|
+
export type ZohoDeskFactory = (config: ZohoDeskConfig) => ZohoDesk;
|
|
33
|
+
/**
|
|
34
|
+
* Creates a {@link ZohoDeskFactory} from the given configuration.
|
|
35
|
+
*
|
|
36
|
+
* The factory pre-initializes shared resources (access token provider, rate limiter)
|
|
37
|
+
* once, then produces {@link ZohoDesk} client instances for each {@link ZohoDeskConfig}.
|
|
38
|
+
* Each client handles OAuth token refresh on {@link ZohoInvalidTokenError}, rate limiting,
|
|
39
|
+
* and Zoho Desk's non-standard error responses (200 status with error body).
|
|
40
|
+
*
|
|
41
|
+
* Unlike CRM/Recruit/Sign, the Desk API requires an `orgId` header on every request.
|
|
42
|
+
* This is injected automatically from the config.
|
|
43
|
+
*
|
|
44
|
+
* @param factoryConfig - Configuration providing account credentials and optional overrides
|
|
45
|
+
* @returns A factory function that creates authenticated Zoho Desk clients
|
|
46
|
+
*/
|
|
47
|
+
export declare function zohoDeskFactory(factoryConfig: ZohoDeskFactoryConfig): ZohoDeskFactory;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type Maybe } from '@dereekb/util';
|
|
2
|
+
import { type ZohoRateLimitResponseDetails, type ZohoRateLimitedFetchHandler, type ZohoRateLimitedFetchHandlerConfig } from '../zoho.limit';
|
|
3
|
+
/**
|
|
4
|
+
* Header name for the credit weight consumed by the last Zoho Desk API request.
|
|
5
|
+
*/
|
|
6
|
+
export declare const ZOHO_DESK_RATE_LIMIT_WEIGHT_HEADER = "X-Rate-Limit-Request-Weight-v3";
|
|
7
|
+
/**
|
|
8
|
+
* Header name for the remaining API credits in the current Zoho Desk rate limit window.
|
|
9
|
+
*/
|
|
10
|
+
export declare const ZOHO_DESK_RATE_LIMIT_REMAINING_HEADER = "X-Rate-Limit-Remaining-v3";
|
|
11
|
+
/**
|
|
12
|
+
* Header name indicating how many seconds to wait before retrying after a Zoho Desk 429 response.
|
|
13
|
+
*/
|
|
14
|
+
export declare const ZOHO_DESK_RETRY_AFTER_HEADER = "Retry-After";
|
|
15
|
+
/**
|
|
16
|
+
* Default rate limit for Zoho Desk API requests (credits per minute).
|
|
17
|
+
*/
|
|
18
|
+
export declare const DEFAULT_ZOHO_DESK_API_RATE_LIMIT = 200;
|
|
19
|
+
/**
|
|
20
|
+
* Reads rate limit details from Zoho Desk v3 response headers.
|
|
21
|
+
*
|
|
22
|
+
* Desk uses a credit-based system with `X-Rate-Limit-Remaining-v3` and `Retry-After` (in seconds)
|
|
23
|
+
* rather than the `X-RATELIMIT-*` headers used by CRM/Recruit/Sign.
|
|
24
|
+
*
|
|
25
|
+
* @param headers - HTTP response headers from a Zoho Desk API call
|
|
26
|
+
* @returns Parsed rate limit details, or null if the Desk rate limit headers are absent
|
|
27
|
+
*/
|
|
28
|
+
export declare function zohoDeskRateLimitDetailsReader(headers: Headers): Maybe<ZohoRateLimitResponseDetails>;
|
|
29
|
+
/**
|
|
30
|
+
* Creates a {@link ZohoRateLimitedFetchHandler} configured for Zoho Desk's v3 rate limit headers.
|
|
31
|
+
*
|
|
32
|
+
* This is a convenience wrapper around {@link makeZohoRateLimitedFetchHandler} pre-configured
|
|
33
|
+
* with the Desk-specific header reader. Unlike CRM, Desk does not provide a total limit header,
|
|
34
|
+
* so the configured `maxRateLimit` (defaulting to {@link DEFAULT_ZOHO_DESK_API_RATE_LIMIT}) is used throughout.
|
|
35
|
+
*
|
|
36
|
+
* @param config - Optional configuration for rate limit, reset period, and 429 handling
|
|
37
|
+
* @returns A rate-limited fetch handler with the underlying rate limiter accessible via `_rateLimiter`
|
|
38
|
+
*/
|
|
39
|
+
export declare function zohoDeskRateLimitedFetchHandler(config?: Maybe<ZohoRateLimitedFetchHandlerConfig>): ZohoRateLimitedFetchHandler;
|