@theholocron/zendesk-client 1.58.0-alpha.3 → 1.58.0-alpha.31
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/dist/index.d.mts +294 -0
- package/dist/index.mjs +36 -0
- package/package.json +18 -18
package/dist/index.d.mts
CHANGED
|
@@ -1,249 +1,467 @@
|
|
|
1
1
|
import { RestClient } from "@theholocron/http-client";
|
|
2
2
|
import { ErrorSink, Logger } from "@theholocron/observability/core";
|
|
3
|
+
/** Fields shared by paginated Zendesk API responses. */
|
|
3
4
|
interface IAPIResponse {
|
|
5
|
+
/** The URL of the next page, or null/absent if this is the last page. */
|
|
4
6
|
next_page?: string | null;
|
|
7
|
+
/** The URL of the previous page, or null/absent if this is the first page. */
|
|
5
8
|
previous_page?: string | null;
|
|
9
|
+
/** The total number of records. */
|
|
6
10
|
count: number;
|
|
7
11
|
}
|
|
12
|
+
/** The error body returned by the Zendesk API. */
|
|
8
13
|
interface IAPIError {
|
|
14
|
+
/** A short error code or name. */
|
|
9
15
|
error: string;
|
|
16
|
+
/** A description of the error. */
|
|
10
17
|
description: string;
|
|
11
18
|
}
|
|
19
|
+
/** An image file stored by Zendesk, such as an attachment or one of its thumbnails. */
|
|
12
20
|
interface IImage {
|
|
21
|
+
/** The MIME type of the file. */
|
|
13
22
|
content_type?: string | null;
|
|
23
|
+
/** The URL to download the file from. */
|
|
14
24
|
content_url?: string | null;
|
|
25
|
+
/** Whether the file has been deleted. */
|
|
15
26
|
deleted?: boolean | null;
|
|
27
|
+
/** The name of the file. */
|
|
16
28
|
file_name?: string | null;
|
|
29
|
+
/** The height of the image in pixels. */
|
|
17
30
|
height?: number | null;
|
|
31
|
+
/** The id of the file, assigned by Zendesk. */
|
|
18
32
|
id?: number | null;
|
|
33
|
+
/** Whether the file is shown inline in the comment body. */
|
|
19
34
|
inline?: boolean | null;
|
|
35
|
+
/** Whether the malware-scan block on the file has been overridden. */
|
|
20
36
|
malware_access_override?: boolean | null;
|
|
37
|
+
/** Outcome of Zendesk's malware scan of the file. */
|
|
21
38
|
malware_scan_result?: "malware_found" | "malware_not_found" | "failed_to_scan" | "not_scanned" | null;
|
|
39
|
+
/** The URL where the file is served from, as mapped by Zendesk. */
|
|
22
40
|
mapped_content_url?: string | null;
|
|
41
|
+
/** The size of the file in bytes. */
|
|
23
42
|
size?: number | null;
|
|
43
|
+
/** The API URL of the file record. */
|
|
24
44
|
url?: string | null;
|
|
45
|
+
/** The width of the image in pixels. */
|
|
25
46
|
width?: number | null;
|
|
26
47
|
}
|
|
48
|
+
/** A file attached to a comment, with its generated thumbnails. */
|
|
27
49
|
interface IAttachment extends IImage {
|
|
50
|
+
/** Thumbnails Zendesk generated for the attachment. */
|
|
28
51
|
thumbnails?: IImage[];
|
|
29
52
|
}
|
|
53
|
+
/** Fixture for an image record, for use in tests. */
|
|
30
54
|
export declare const mockImage: IImage;
|
|
55
|
+
/** Fixture for an attachment thumbnail image, for use in tests. */
|
|
31
56
|
export declare const mockThumbnail: IImage;
|
|
57
|
+
/** Fixture for an attachment that carries a thumbnail, for use in tests. */
|
|
32
58
|
export declare const mockAttachment: IAttachment;
|
|
59
|
+
/** A Zendesk user: an end user, agent or admin. */
|
|
33
60
|
interface IUser {
|
|
61
|
+
/** False if the user has been deleted. */
|
|
34
62
|
active?: boolean | null;
|
|
63
|
+
/** An alias displayed to end users. */
|
|
35
64
|
alias?: string | null;
|
|
65
|
+
/** Whether or not the user is a chat-only agent. */
|
|
36
66
|
chat_only?: boolean | null;
|
|
67
|
+
/** The time the user was created. */
|
|
37
68
|
created_at?: string | null;
|
|
69
|
+
/** A custom role if the user is an agent on the Enterprise plan or above. */
|
|
38
70
|
custom_role_id?: number | null;
|
|
71
|
+
/** The id of the user's default group. */
|
|
39
72
|
default_group_id?: number | null;
|
|
73
|
+
/** Any details you want to store about the user, such as an address. */
|
|
40
74
|
details?: string | null;
|
|
75
|
+
/** The user's primary email address. *Writeable on create only. On update, a secondary email is added. See Email Address. */
|
|
41
76
|
email?: string | null;
|
|
77
|
+
/** A unique identifier from another system. The API treats the id as case insensitive. Example: "ian1" and "IAN1" are the same value. */
|
|
42
78
|
external_id?: string | null;
|
|
79
|
+
/** The time zone for the user. */
|
|
43
80
|
iana_time_zone?: string | null;
|
|
81
|
+
/** Automatically assigned when the user is created. */
|
|
44
82
|
id?: number | null;
|
|
83
|
+
/** Last time the user signed in to Zendesk Support or made an API request using an API token or basic authentication. */
|
|
45
84
|
last_login_at?: string | null;
|
|
85
|
+
/** The user's locale. A BCP-47 compliant tag for the locale. If both "locale" and "locale_id" are present on create or update, "locale_id" is ignored and only "locale" is used. */
|
|
46
86
|
locale?: string | null;
|
|
87
|
+
/** The user's language identifier. */
|
|
47
88
|
locale_id?: number | null;
|
|
89
|
+
/** Designates whether the user has forum moderation capabilities. */
|
|
48
90
|
moderator?: boolean | null;
|
|
91
|
+
/** The user's name. */
|
|
49
92
|
name: string | null;
|
|
93
|
+
/** Any notes you want to store about the user. */
|
|
50
94
|
notes?: string | null;
|
|
95
|
+
/** True if the user can only create private comments. */
|
|
51
96
|
only_private_comments?: boolean | null;
|
|
97
|
+
/** The id of the user's organization. If the user has more than one organization memberships, the id of the user's default organization. If updating, see Organization ID. */
|
|
52
98
|
organization_id?: number | null;
|
|
99
|
+
/** The user's primary phone number. See Phone Number below. */
|
|
53
100
|
phone?: string | null;
|
|
101
|
+
/** The user's profile picture represented as an Attachment object. */
|
|
54
102
|
photo?: IAttachment | null;
|
|
103
|
+
/** A URL pointing to the user's profile picture. */
|
|
55
104
|
remote_photo_url?: string | null;
|
|
105
|
+
/** This parameter is inert and has no effect. It may be deprecated in the future. Previously, this parameter determined whether a user could access a CSV report in a legacy Guide dashboard. This dashboard has been removed. See Announcing Guide legacy reporting upgrade to Explore. */
|
|
56
106
|
report_csv?: boolean | null;
|
|
107
|
+
/** If the agent has any restrictions; false for admins and unrestricted agents, true for other agents. */
|
|
57
108
|
restricted_agent?: boolean | null;
|
|
109
|
+
/** The user's role. */
|
|
58
110
|
role?: "end-user" | "agent" | "admin" | null;
|
|
111
|
+
/** The user's role id. 0 for a custom agent, 1 for a light agent, 2 for a chat agent, 3 for a chat agent added to the Support account as a contributor (Chat Phase 4), 4 for an admin, and 5 for a billing admin. */
|
|
59
112
|
role_type?: 0 | 1 | 2 | 3 | 4 | 5 | null;
|
|
113
|
+
/** If the user is shared from a different Zendesk Support instance. Ticket sharing accounts only. */
|
|
60
114
|
shared?: boolean | null;
|
|
115
|
+
/** If the user is a shared agent from a different Zendesk Support instance. Ticket sharing accounts only. */
|
|
61
116
|
shared_agent?: boolean | null;
|
|
117
|
+
/** Whether the phone number is shared or not. See Phone Number below. */
|
|
62
118
|
shared_phone_number?: boolean | null;
|
|
119
|
+
/** The user's signature. Only agents and admins can have signatures. */
|
|
63
120
|
signature?: string | null;
|
|
121
|
+
/** If the agent is suspended. Tickets from suspended users are also suspended, and these users cannot sign in to the end user portal. */
|
|
64
122
|
suspended?: boolean | null;
|
|
123
|
+
/** The user's tags. Only present if your account has user tagging enabled. */
|
|
65
124
|
tags?: string[] | null;
|
|
125
|
+
/** Specifies which tickets the user has access to. */
|
|
66
126
|
ticket_restriction?: "organization" | "groups" | "assigned" | "requested" | null;
|
|
127
|
+
/** The user's time zone. See Time Zone. */
|
|
67
128
|
time_zone?: string | null;
|
|
129
|
+
/** If two-factor authentication is enabled. */
|
|
68
130
|
two_factor_auth_enabled?: boolean | null;
|
|
131
|
+
/** The time the user was last updated. */
|
|
69
132
|
updated_at?: string | null;
|
|
133
|
+
/** The user's API url. */
|
|
70
134
|
url?: string | null;
|
|
135
|
+
/** Values of custom fields in the user's profile. See User Fields. */
|
|
71
136
|
user_fields?: Record<string, unknown> | null;
|
|
137
|
+
/** Any of the user's identities is verified. See User Identities. */
|
|
72
138
|
verified?: boolean | null;
|
|
73
139
|
}
|
|
140
|
+
/** An entry in the agent's ticket activity stream, as returned by the Zendesk API. */
|
|
74
141
|
interface IActivity {
|
|
142
|
+
/** The full user record of the user responsible for the ticket activity. See Users. */
|
|
75
143
|
actor?: IUser | null;
|
|
144
|
+
/** The id of the user responsible for the ticket activity. An actor_id of "-1" is a Zendesk system user, such as an automations action. */
|
|
76
145
|
actor_id?: number | null;
|
|
146
|
+
/** When the record was created. */
|
|
77
147
|
created_at?: string | null;
|
|
148
|
+
/** Automatically assigned on creation. */
|
|
78
149
|
id?: number | null;
|
|
150
|
+
/** The content of the activity. Can be a ticket, comment, or change. */
|
|
79
151
|
object?: Record<string, unknown> | null;
|
|
152
|
+
/** The target of the activity, a ticket. */
|
|
80
153
|
target?: Record<string, unknown> | null;
|
|
154
|
+
/** Description of the activity. */
|
|
81
155
|
title?: string | null;
|
|
156
|
+
/** When the record was last updated. */
|
|
82
157
|
updated_at?: string | null;
|
|
158
|
+
/** The API url of the activity. */
|
|
83
159
|
url?: string | null;
|
|
160
|
+
/** The full user record of the agent making the request. See Users. */
|
|
84
161
|
user?: IUser | null;
|
|
162
|
+
/** The id of the agent making the request. */
|
|
85
163
|
user_id?: number | null;
|
|
164
|
+
/** The type of activity. */
|
|
86
165
|
verb?: "tickets.assignment" | "tickets.comment" | "tickets.priority_increase" | null;
|
|
87
166
|
}
|
|
167
|
+
/** A page of ticket activities from the Zendesk API, with the users they refer to. */
|
|
88
168
|
interface IActivityResponse extends IAPIResponse {
|
|
169
|
+
/** The activities on this page. */
|
|
89
170
|
activities: IActivity[];
|
|
171
|
+
/** The users responsible for the activities (the actors). */
|
|
90
172
|
actors: IUser[];
|
|
173
|
+
/** The users referenced by the activities. */
|
|
91
174
|
users: IUser[];
|
|
92
175
|
}
|
|
176
|
+
/** The value of one custom field on a ticket, set by field id. */
|
|
93
177
|
interface ICustomField {
|
|
178
|
+
/** The id of the custom ticket field. */
|
|
94
179
|
id: number | null;
|
|
180
|
+
/** The value of the field; a list of strings for multi-select fields. */
|
|
95
181
|
value: string | number | string[] | null;
|
|
96
182
|
}
|
|
183
|
+
/** A ticket field definition, either a system field or a custom one. */
|
|
97
184
|
interface ITicketField {
|
|
185
|
+
/** Whether this field is available. */
|
|
98
186
|
active?: boolean | null;
|
|
187
|
+
/** A description of the ticket field that only agents can see. */
|
|
99
188
|
agent_description?: string | null;
|
|
189
|
+
/** If true, the field is shown to agents by default. If false, the field is hidden alongside infrequently used fields. Classic interface only. */
|
|
100
190
|
collapsed_for_agents?: boolean | null;
|
|
191
|
+
/** The time the custom ticket field was created. */
|
|
101
192
|
created_at?: string | null;
|
|
193
|
+
/** Required and presented for a custom ticket field of type "multiselect" or "tagger". */
|
|
102
194
|
custom_field_options?: Array<unknown> | null;
|
|
195
|
+
/** List of customized ticket statuses. Only presented for a system ticket field of type "custom_status". */
|
|
103
196
|
custom_statuses?: Array<unknown> | null;
|
|
197
|
+
/** Describes the purpose of the ticket field to users. */
|
|
104
198
|
description?: string | null;
|
|
199
|
+
/** Whether this field is editable by end users in Help Center. */
|
|
105
200
|
editable_in_portal?: boolean | null;
|
|
201
|
+
/** Automatically assigned when created. */
|
|
106
202
|
id?: number | null;
|
|
203
|
+
/** The relative position of the ticket field on a ticket. Note that for accounts with ticket forms, positions are controlled by the different forms. */
|
|
107
204
|
position?: number | null;
|
|
205
|
+
/** The dynamic content placeholder if present, or the description value if not. See Dynamic Content. */
|
|
108
206
|
raw_description?: string | null;
|
|
207
|
+
/** The dynamic content placeholder if present, or the title value if not. See Dynamic Content. */
|
|
109
208
|
raw_title?: string | null;
|
|
209
|
+
/** The dynamic content placeholder if present, or the "title_in_portal" value if not. See Dynamic Content. */
|
|
110
210
|
raw_title_in_portal?: string | null;
|
|
211
|
+
/** For "regexp" fields only. The validation pattern for a field value to be deemed valid. */
|
|
111
212
|
regexp_for_validation?: string | null;
|
|
213
|
+
/** A filter definition that allows your autocomplete to filter down results. */
|
|
112
214
|
relationship_filter?: Record<string, unknown> | null;
|
|
215
|
+
/** A representation of what type of object the field references. Options are "zen:user", "zen:organization", "zen:ticket", or "zen:custom_object:CUSTOM_OBJECT_KEY". For example "zen:custom_object:apartment". */
|
|
113
216
|
relationship_target_type?: string | null;
|
|
217
|
+
/** If false, this field is a system field that must be present on all tickets. */
|
|
114
218
|
removable?: boolean | null;
|
|
219
|
+
/** If true, agents must enter a value in the field to change the ticket status to solved. */
|
|
115
220
|
required?: boolean | null;
|
|
221
|
+
/** If true, end users must enter a value in the field to create the request. */
|
|
116
222
|
required_in_portal?: boolean | null;
|
|
223
|
+
/** For system ticket fields of type "priority" and "status". Defaults to 0. A "priority" sub type of 1 removes the "Low" and "Urgent" options. A "status" sub type of 1 adds the "On-Hold" option. */
|
|
117
224
|
sub_type_id?: number | null;
|
|
225
|
+
/** Presented for a system ticket field of type "tickettype", "priority" or "status". */
|
|
118
226
|
system_field_options?: Array<unknown> | null;
|
|
227
|
+
/** For "checkbox" fields only. A tag added to tickets when the checkbox field is selected. */
|
|
119
228
|
tag?: string | null;
|
|
229
|
+
/** The title of the ticket field. */
|
|
120
230
|
title: string | null;
|
|
231
|
+
/** The title of the ticket field for end users in Help Center. */
|
|
121
232
|
title_in_portal?: string | null;
|
|
233
|
+
/** System or custom field type. Editable for custom field types and only on creation. See Create Ticket Field. */
|
|
122
234
|
type: string | null;
|
|
235
|
+
/** The time the custom ticket field was last updated. */
|
|
123
236
|
updated_at?: string | null;
|
|
237
|
+
/** The URL for this resource. */
|
|
124
238
|
url?: string | null;
|
|
239
|
+
/** Whether this field is visible to end users in Help Center. */
|
|
125
240
|
visible_in_portal?: boolean | null;
|
|
126
241
|
}
|
|
242
|
+
/** A page of ticket field definitions from the Zendesk API. */
|
|
127
243
|
type TTicketFieldsResponse = IAPIResponse & {
|
|
128
244
|
ticket_fields: ITicketField[];
|
|
129
245
|
};
|
|
246
|
+
/** A response holding a single ticket field definition. */
|
|
130
247
|
type TTicketFieldResponse = IAPIResponse & {
|
|
131
248
|
ticket_field: ITicketField;
|
|
132
249
|
};
|
|
250
|
+
/** The state of a ticket. */
|
|
133
251
|
type TTicketStatus = "new" | "open" | "pending" | "hold" | "solved" | "closed";
|
|
252
|
+
/** The urgency of a ticket. */
|
|
134
253
|
type TTicketPriority = "urgent" | "high" | "normal" | "low";
|
|
254
|
+
/** The kind of a ticket. */
|
|
135
255
|
type TTicketType = "problem" | "incident" | "question" | "task";
|
|
256
|
+
/** Describes how a ticket or comment was created. */
|
|
136
257
|
interface IVia {
|
|
258
|
+
/** The channel the ticket came through, such as "web" or "email", or a numeric channel id. */
|
|
137
259
|
channel: string | number | null;
|
|
260
|
+
/** Where the request came from and went to. */
|
|
138
261
|
source?: {
|
|
262
|
+
/** The origin of the request. */
|
|
139
263
|
from?: Record<string, unknown>;
|
|
264
|
+
/** The relationship of the source to the ticket. */
|
|
140
265
|
rel?: string | null;
|
|
266
|
+
/** The destination of the request. */
|
|
141
267
|
to?: Record<string, unknown>;
|
|
142
268
|
};
|
|
143
269
|
}
|
|
270
|
+
/** System information and via details attached to a ticket or comment. */
|
|
144
271
|
interface IMetadata {
|
|
272
|
+
/** Details about the client that created the record. */
|
|
145
273
|
system?: {
|
|
274
|
+
/** The client (such as the browser) that created the record. */
|
|
146
275
|
client?: string | null;
|
|
276
|
+
/** The IP address the record was created from. */
|
|
147
277
|
ip_address?: string | null;
|
|
278
|
+
/** The latitude of the client's location. */
|
|
148
279
|
latitude?: number | null;
|
|
280
|
+
/** The location of the client, as a place name. */
|
|
149
281
|
location?: string | null;
|
|
282
|
+
/** The longitude of the client's location. */
|
|
150
283
|
longitude?: number | null;
|
|
151
284
|
};
|
|
285
|
+
/** How the record was created. */
|
|
152
286
|
via: IVia;
|
|
153
287
|
}
|
|
288
|
+
/** A Zendesk support ticket; some fields are write-only and only apply when creating or updating. */
|
|
154
289
|
interface ITicket {
|
|
290
|
+
/** Permission for agents to add add attachments to a comment. Defaults to true. */
|
|
155
291
|
allow_attachments?: boolean | null;
|
|
292
|
+
/** Is false if channelback is disabled, true otherwise. Only applicable for channels framework ticket. */
|
|
156
293
|
allow_channelback?: boolean | null;
|
|
294
|
+
/** Write only. The email address of the agent to assign the ticket to. */
|
|
157
295
|
assignee_email?: string | null;
|
|
296
|
+
/** The agent currently assigned to the ticket. */
|
|
158
297
|
assignee_id?: number | null;
|
|
298
|
+
/** Write only. An array of the IDs of attribute values to be associated with the ticket. */
|
|
159
299
|
attribute_value_ids?: string[] | null;
|
|
300
|
+
/** Enterprise only. The id of the brand this ticket is associated with. */
|
|
160
301
|
brand_id?: number | null;
|
|
302
|
+
/** The ids of users currently CC'ed on the ticket. */
|
|
161
303
|
collaborator_ids?: number[] | null;
|
|
304
|
+
/** POST requests only. Users to add as cc's when creating a ticket. See Setting Collaborators. */
|
|
162
305
|
collaborators?: Array<unknown> | null;
|
|
306
|
+
/** Write only. An object that adds a comment to the ticket. See Ticket comments. To include an attachment with the comment, see Attaching files. */
|
|
163
307
|
comment?: IComment | null;
|
|
308
|
+
/** When this record was created. */
|
|
164
309
|
created_at?: string | null;
|
|
310
|
+
/** Custom fields for the ticket. See Setting custom field values. */
|
|
165
311
|
custom_fields?: ICustomField[] | null;
|
|
312
|
+
/** The custom ticket status id of the ticket. See custom ticket statuses. */
|
|
166
313
|
custom_status_id?: number | null;
|
|
314
|
+
/** Read-only first comment on the ticket. When creating a ticket, use comment to set the description. See Description and first comment. */
|
|
167
315
|
description?: string | null;
|
|
316
|
+
/** If this is a ticket of type "task" it has a due date. Due date format uses ISO 8601 format. */
|
|
168
317
|
due_at?: string | null;
|
|
318
|
+
/** The ids of agents or end users currently CC'ed on the ticket. See CCs and followers resources in the Support Help Center. */
|
|
169
319
|
email_cc_ids?: number[] | null;
|
|
320
|
+
/** Write only. An array of objects that represent agent or end users email CCs to add or delete from the ticket. See Setting email CCs. */
|
|
170
321
|
email_ccs?: Array<Record<string, unknown>>;
|
|
322
|
+
/** An id you can use to link Zendesk Support tickets to local records. */
|
|
171
323
|
external_id?: string | null;
|
|
324
|
+
/** The ids of agents currently following the ticket. See CCs and followers resources. */
|
|
172
325
|
follower_ids?: number[] | null;
|
|
326
|
+
/** Write only. An array of objects that represent agent followers to add or delete from the ticket. See Setting followers. */
|
|
173
327
|
followers?: Array<Record<string, unknown>>;
|
|
328
|
+
/** The ids of the followups created from this ticket. Ids are only visible once the ticket is closed. */
|
|
174
329
|
followup_ids?: number[] | null;
|
|
330
|
+
/** The topic in the Zendesk Web portal this ticket originated from, if any. The Web portal is deprecated. */
|
|
175
331
|
forum_topic_id?: number | null;
|
|
332
|
+
/** If true, the ticket's via type is a messaging channel. */
|
|
176
333
|
from_messaging_channel?: boolean | null;
|
|
334
|
+
/** The group this ticket is assigned to. */
|
|
177
335
|
group_id?: number | null;
|
|
336
|
+
/** Is true if a ticket is a problem type and has one or more incidents linked to it. Otherwise, the value is false. */
|
|
178
337
|
has_incidents?: boolean | null;
|
|
338
|
+
/** Automatically assigned when the ticket is created. */
|
|
179
339
|
id?: number | null;
|
|
340
|
+
/** Is true if any comments are public, false otherwise. */
|
|
180
341
|
is_public?: boolean | null;
|
|
342
|
+
/** Write only. A macro ID to be recorded in the ticket audit. */
|
|
181
343
|
macro_id?: number | null;
|
|
344
|
+
/** POST requests only. List of macro IDs to be recorded in the ticket audit. */
|
|
182
345
|
macro_ids?: number[] | null;
|
|
346
|
+
/** Write only. Metadata for the audit. In the audit object, the data is specified in the custom property of the metadata object. See Setting Metadata. */
|
|
183
347
|
metadata?: IMetadata | null;
|
|
348
|
+
/** The organization of the requester. You can only specify the ID of an organization associated with the requester. See Organization Memberships. */
|
|
184
349
|
organization_id?: number | null;
|
|
350
|
+
/** The urgency with which the ticket should be addressed. */
|
|
185
351
|
priority?: TTicketPriority | null;
|
|
352
|
+
/** For tickets of type "incident", the ID of the problem the incident is linked to. */
|
|
186
353
|
problem_id?: number | null;
|
|
354
|
+
/** The dynamic content placeholder, if present, or the "subject" value, if not. See Dynamic Content Items. */
|
|
187
355
|
raw_subject?: string | null;
|
|
356
|
+
/** The original recipient e-mail address of the ticket. Notification emails for the ticket are sent from this address. */
|
|
188
357
|
recipient?: string | null;
|
|
358
|
+
/** Write only. See Creating a ticket with a new requester. */
|
|
189
359
|
requester?: Record<string, unknown>;
|
|
360
|
+
/** The user who requested this ticket. */
|
|
190
361
|
requester_id: number | null;
|
|
362
|
+
/** Write only. Optional boolean. When true and an update_stamp date is included, protects against ticket update collisions and returns a message to let you know if one occurs. See Protecting against ticket update collisions. A value of false has the same effect as true. Omit the property to force the updates to not be safe. */
|
|
191
363
|
safe_update?: boolean | null;
|
|
364
|
+
/** The satisfaction rating of the ticket, if it exists, or the state of satisfaction, "offered" or "unoffered". The value is null for plan types that don't support CSAT. */
|
|
192
365
|
satisfaction_rating?: Record<string, unknown>;
|
|
366
|
+
/** The ids of the sharing agreements used for this ticket. */
|
|
193
367
|
sharing_agreement_ids?: number[] | null;
|
|
368
|
+
/** The state of the ticket. If your account has activated custom ticket statuses, this is the ticket's status category. See custom ticket statuses. */
|
|
194
369
|
status?: TTicketStatus | null;
|
|
370
|
+
/** The value of the subject field for this ticket. */
|
|
195
371
|
subject?: string | null;
|
|
372
|
+
/** The user who submitted the ticket. The submitter always becomes the author of the first comment on the ticket. */
|
|
196
373
|
submitter_id?: number | null;
|
|
374
|
+
/** The array of tags applied to this ticket. */
|
|
197
375
|
tags?: string[] | null;
|
|
376
|
+
/** Enterprise only. The id of the ticket form to render for the ticket. */
|
|
198
377
|
ticket_form_id?: number | null;
|
|
378
|
+
/** The type of this ticket. */
|
|
199
379
|
type?: TTicketType | null;
|
|
380
|
+
/** When this record last got updated. */
|
|
200
381
|
updated_at?: string | null;
|
|
382
|
+
/** Write only. Datetime of last update received from API. See the safe_update property. */
|
|
201
383
|
updated_stamp?: string | null;
|
|
384
|
+
/** The API url of this ticket. */
|
|
202
385
|
url?: string | null;
|
|
386
|
+
/** For more information, see the Via object reference. */
|
|
203
387
|
via?: IVia | null;
|
|
388
|
+
/** POST requests only. The id of a closed ticket when creating a follow-up ticket. See Creating a follow-up ticket. */
|
|
204
389
|
via_followup_source_id?: number | null;
|
|
390
|
+
/** Write only. For more information, see the Via object reference. */
|
|
205
391
|
via_id?: number | null;
|
|
392
|
+
/** Write only. See Creating voicemail ticket. */
|
|
206
393
|
voice_comment?: Record<string, unknown>;
|
|
207
394
|
}
|
|
395
|
+
/** A page of tickets from the Zendesk API. */
|
|
208
396
|
type TTicketsResponse = IAPIResponse & {
|
|
209
397
|
tickets: ITicket[];
|
|
210
398
|
deleted_ticket_forms?: Array<unknown>;
|
|
211
399
|
};
|
|
400
|
+
/** A response holding a single ticket. */
|
|
212
401
|
type TTicketResponse = IAPIResponse & {
|
|
213
402
|
ticket: ITicket;
|
|
214
403
|
deleted_ticket_forms?: Array<unknown>;
|
|
215
404
|
};
|
|
405
|
+
/** A comment on a Zendesk ticket, public or an internal note. */
|
|
216
406
|
interface IComment {
|
|
407
|
+
/** Attachments, if any. See Attachment. */
|
|
217
408
|
attachments?: IAttachment[] | null;
|
|
409
|
+
/** The id of the ticket audit record. See Show Audit. */
|
|
218
410
|
audit_id?: number | null;
|
|
411
|
+
/** The id of the comment author. See Author id. */
|
|
219
412
|
author_id?: number | null;
|
|
413
|
+
/** The comment string. See Bodies. */
|
|
220
414
|
body?: string | null;
|
|
415
|
+
/** The time the comment was created. */
|
|
221
416
|
created_at?: string | null;
|
|
417
|
+
/** The comment formatted as HTML. See Bodies. */
|
|
222
418
|
html_body?: string | null;
|
|
419
|
+
/** Automatically assigned when the comment is created. */
|
|
223
420
|
id?: number | null;
|
|
421
|
+
/** System information (web client, IP address, etc.) and comment flags, if any. See Comment flags. */
|
|
224
422
|
metadata?: IMetadata | null;
|
|
423
|
+
/** The comment presented as plain text. See Bodies. */
|
|
225
424
|
plain_body?: string | null;
|
|
425
|
+
/** true if a public comment; false if an internal note. The initial value set on ticket creation persists for any additional comment unless you change it. */
|
|
226
426
|
public?: boolean | null;
|
|
427
|
+
/** Comment or VoiceComment. The JSON object for adding voice comments to tickets is different. See Adding voice comments to tickets. */
|
|
227
428
|
type?: "Comment" | "VoiceComment" | null;
|
|
429
|
+
/** List of tokens received from uploading files for comment attachments. The files are attached by creating or updating tickets with the tokens. See Attaching files in Tickets. */
|
|
228
430
|
uploads?: string[] | null;
|
|
431
|
+
/** Describes how the object was created. See the Via object reference. */
|
|
229
432
|
via?: IVia | null;
|
|
230
433
|
}
|
|
434
|
+
/** A response holding the comments of a ticket. */
|
|
231
435
|
interface ICommentResponse {
|
|
436
|
+
/** The ticket's comments. */
|
|
232
437
|
comments: IComment[];
|
|
233
438
|
}
|
|
439
|
+
/** A group of agents in Zendesk Support. */
|
|
234
440
|
interface IGroup {
|
|
441
|
+
/** The time the group was created. */
|
|
235
442
|
created_at?: string | null;
|
|
443
|
+
/** If the group is the default one for the account. */
|
|
236
444
|
default?: boolean | null;
|
|
445
|
+
/** Deleted groups get marked as such. */
|
|
237
446
|
deleted?: boolean | null;
|
|
447
|
+
/** The description of the group. */
|
|
238
448
|
description?: string | null;
|
|
449
|
+
/** Automatically assigned when creating groups. */
|
|
239
450
|
id?: number | null;
|
|
451
|
+
/** If true, the group is public. If false, the group is private. You can't change a private group to a public group. */
|
|
240
452
|
is_public?: boolean | null;
|
|
453
|
+
/** The name of the group. */
|
|
241
454
|
name?: string | null;
|
|
455
|
+
/** The time of the last update of the group. */
|
|
242
456
|
updated_at?: string | null;
|
|
457
|
+
/** The API url of the group. */
|
|
243
458
|
url?: string | null;
|
|
244
459
|
}
|
|
460
|
+
/** A page of search results from the Zendesk search API. */
|
|
245
461
|
interface ISearchResponse extends IAPIResponse {
|
|
462
|
+
/** Facet data for the results, if any. */
|
|
246
463
|
facets?: string | null;
|
|
464
|
+
/** The matching records: tickets, users or groups, depending on the query. */
|
|
247
465
|
results: ITicket[] | IUser[] | IGroup[];
|
|
248
466
|
}
|
|
249
467
|
interface IStatus {
|
|
@@ -253,28 +471,47 @@ interface IStatus {
|
|
|
253
471
|
end_user_description?: string | null;
|
|
254
472
|
status_category?: string | null;
|
|
255
473
|
}
|
|
474
|
+
/** One of Zendesk's built-in ticket statuses. */
|
|
256
475
|
interface IDefaultStatus extends IStatus {
|
|
476
|
+
/** The label shown to end users, which is the status name. */
|
|
257
477
|
end_user_label?: "new" | "open" | "pending" | "hold" | "solved" | null;
|
|
258
478
|
}
|
|
479
|
+
/** An account-defined ticket status, on top of the default ones. */
|
|
259
480
|
interface ICustomStatus extends IStatus {
|
|
481
|
+
/** The date and time the custom ticket status was created. */
|
|
260
482
|
created_at?: string | null;
|
|
483
|
+
/** If true, the custom status is set to default. If false, the custom status is set to non-default. */
|
|
261
484
|
default?: boolean | null;
|
|
485
|
+
/** The label displayed to end users. Maximum length is 48 characters. */
|
|
262
486
|
end_user_label?: string | null;
|
|
487
|
+
/** Automatically assigned when the custom ticket status is created. */
|
|
263
488
|
id?: number | null;
|
|
489
|
+
/** The dynamic content placeholder. If the dynamic content placeholder is not available, this is the "agent_label" value. See Dynamic Content Items. */
|
|
264
490
|
raw_agent_label?: string | null;
|
|
491
|
+
/** The dynamic content placeholder. If the dynamic content placeholder is not available, this is the "description" value. Dynamic Content Items. */
|
|
265
492
|
raw_description?: string | null;
|
|
493
|
+
/** The dynamic content placeholder. If the dynamic content placeholder is not available, this is the "end_user_description" value. See Dynamic Content Items. */
|
|
266
494
|
raw_end_user_description?: string | null;
|
|
495
|
+
/** The dynamic content placeholder. If the dynamic content placeholder is not available, this is the "end_user_label" value. See Dynamic Content Items. */
|
|
267
496
|
raw_end_user_label?: string | null;
|
|
497
|
+
/** The date and time the custom ticket status was last updated. */
|
|
268
498
|
updated_at?: string | null;
|
|
499
|
+
/** The API URL of the custom status. */
|
|
269
500
|
url?: string | null;
|
|
270
501
|
}
|
|
502
|
+
/** A page of custom ticket statuses from the Zendesk API. */
|
|
271
503
|
interface ICustomStatusesResponse extends IAPIResponse {
|
|
504
|
+
/** The custom statuses on this page. */
|
|
272
505
|
custom_statuses: ICustomStatus[];
|
|
273
506
|
}
|
|
507
|
+
/** A response holding a single custom ticket status. */
|
|
274
508
|
interface ICustomStatusResponse extends IAPIResponse {
|
|
509
|
+
/** The custom status. */
|
|
275
510
|
custom_status: ICustomStatus;
|
|
276
511
|
}
|
|
512
|
+
/** Encodes a Zendesk API token credential as base64 `user/token:password`, the value the `token` option expects. */
|
|
277
513
|
export declare const createToken: (user: string, password: string) => string;
|
|
514
|
+
/** Options for creating a Zendesk client. */
|
|
278
515
|
interface ZendeskClientOptions {
|
|
279
516
|
/** Base URL of your Zendesk instance, e.g. "https://myorg.zendesk.com". */
|
|
280
517
|
baseUrl: string;
|
|
@@ -287,34 +524,51 @@ interface ZendeskClientOptions {
|
|
|
287
524
|
/** Reports transport failures and unexpected 5xx. Defaults to a no-op. */
|
|
288
525
|
errors?: ErrorSink;
|
|
289
526
|
}
|
|
527
|
+
/** Builds the activities resource of the Zendesk API (`/api/v2/activities`) on top of a REST client. */
|
|
290
528
|
declare function activities(rest: RestClient): {
|
|
291
529
|
get: (params?: Record<string, string>) => Promise<IActivityResponse>;
|
|
292
530
|
};
|
|
531
|
+
/** Fixture for a single ticket activity, for use in tests. */
|
|
293
532
|
export declare const mockActivity: IActivity;
|
|
533
|
+
/** Fixture for a Zendesk activities list response containing `mockActivity`. */
|
|
294
534
|
export declare const mockActivityResponse: IActivityResponse;
|
|
535
|
+
/** Fixture for a Zendesk group, for use in tests. */
|
|
295
536
|
export declare const mockGroup: IGroup;
|
|
537
|
+
/** Builds the search resource of the Zendesk API (`/api/v2/search`) on top of a REST client; `query` sorts descending by default. */
|
|
296
538
|
declare function search(rest: RestClient): {
|
|
297
539
|
query: (q: string, params?: Record<string, string>) => Promise<ISearchResponse>;
|
|
298
540
|
};
|
|
541
|
+
/** Fixture for a search response whose results are groups. */
|
|
299
542
|
export declare const mockSearchResponseGroups: ISearchResponse;
|
|
543
|
+
/** Fixture for a search response whose results are tickets. */
|
|
300
544
|
export declare const mockSearchResponseTickets: ISearchResponse;
|
|
545
|
+
/** Fixture for a search response whose results are users. */
|
|
301
546
|
export declare const mockSearchResponseUsers: ISearchResponse;
|
|
547
|
+
/** Builds the custom ticket statuses resource of the Zendesk API (`/api/v2/custom_statuses`) on top of a REST client. */
|
|
302
548
|
declare function status(rest: RestClient): {
|
|
303
549
|
list: () => Promise<ICustomStatusesResponse>;
|
|
304
550
|
get: (id: number) => Promise<ICustomStatusResponse>;
|
|
305
551
|
create: (data: ICustomStatus) => Promise<ICustomStatusResponse>;
|
|
306
552
|
update: (id: number, data: Partial<ICustomStatus>) => Promise<ICustomStatusResponse>;
|
|
307
553
|
};
|
|
554
|
+
/** Fixture for a default (system) ticket status, for use in tests. */
|
|
308
555
|
export declare const mockDefaultStatus: IDefaultStatus;
|
|
556
|
+
/** Fixture for a custom ticket status, for use in tests. */
|
|
309
557
|
export declare const mockCustomStatus: ICustomStatus;
|
|
558
|
+
/** Fixture for a list-of-custom-statuses response, for use in tests. */
|
|
310
559
|
export declare const mockCustomStatusesResponse: ICustomStatusesResponse;
|
|
560
|
+
/** Fixture for a single custom status response, for use in tests. */
|
|
311
561
|
export declare const mockCustomStatusResponse: ICustomStatusResponse;
|
|
562
|
+
/** Builds the ticket comments resource of the Zendesk API (`/api/v2/tickets/{id}/comments`) on top of a REST client. */
|
|
312
563
|
declare function comments(rest: RestClient): {
|
|
313
564
|
list: (ticketId: number) => Promise<ICommentResponse>;
|
|
314
565
|
create: (ticketId: number, body: string) => Promise<void>;
|
|
315
566
|
};
|
|
567
|
+
/** Fixture for a ticket comment, for use in tests. */
|
|
316
568
|
export declare const mockComment: IComment;
|
|
569
|
+
/** Fixture for a ticket comments response, for use in tests. */
|
|
317
570
|
export declare const mockCommentResponse: ICommentResponse;
|
|
571
|
+
/** Builds the ticket fields resource of the Zendesk API (`/api/v2/ticket_fields`) on top of a REST client. */
|
|
318
572
|
declare function fields(rest: RestClient): {
|
|
319
573
|
list: () => Promise<TTicketFieldsResponse>;
|
|
320
574
|
get: (id: number) => Promise<TTicketFieldResponse>;
|
|
@@ -322,44 +576,77 @@ declare function fields(rest: RestClient): {
|
|
|
322
576
|
update: (id: number, data: Partial<ITicketField>) => Promise<TTicketFieldResponse>;
|
|
323
577
|
delete: (id: number) => Promise<void>;
|
|
324
578
|
};
|
|
579
|
+
/** Fixture for a first custom field value on a ticket, for use in tests. */
|
|
325
580
|
export declare const mockCustomField1: ICustomField;
|
|
581
|
+
/** Fixture for a second custom field value on a ticket, for use in tests. */
|
|
326
582
|
export declare const mockCustomField2: ICustomField;
|
|
583
|
+
/** Fixture for a list of custom field values, for use in tests. */
|
|
327
584
|
export declare const mockCustomFields: ICustomField[];
|
|
585
|
+
/** Fixture for a ticket field definition, for use in tests. */
|
|
328
586
|
export declare const mockTicketField: ITicketField;
|
|
587
|
+
/** Fixture for a list-of-ticket-fields response, for use in tests. */
|
|
329
588
|
export declare const mockTicketFieldsResponse: TTicketFieldsResponse;
|
|
589
|
+
/** Fixture for a single ticket field response, for use in tests. */
|
|
330
590
|
export declare const mockTicketFieldResponse: TTicketFieldResponse;
|
|
331
591
|
interface ITimeInMinutes {
|
|
332
592
|
business: number;
|
|
333
593
|
calendar: number;
|
|
334
594
|
}
|
|
595
|
+
/** Time and activity metrics Zendesk records for a ticket. */
|
|
335
596
|
interface ITicketMetric {
|
|
597
|
+
/** Minutes the agent waited on the ticket. */
|
|
336
598
|
agent_wait_time_in_minutes: ITimeInMinutes;
|
|
599
|
+
/** When the ticket was last assigned (ISO 8601). */
|
|
337
600
|
assigned_at: string;
|
|
601
|
+
/** The number of agents the ticket has been assigned to. */
|
|
338
602
|
assignee_stations: number;
|
|
603
|
+
/** When the assignee last updated the ticket (ISO 8601). */
|
|
339
604
|
assignee_updated_at: string;
|
|
605
|
+
/** When the metric record was created (ISO 8601). */
|
|
340
606
|
created_at: string;
|
|
607
|
+
/** When the custom ticket status last changed (ISO 8601). */
|
|
341
608
|
custom_status_updated_at: string;
|
|
609
|
+
/** Minutes until the ticket was first resolved. */
|
|
342
610
|
first_resolution_time_in_minutes: ITimeInMinutes;
|
|
611
|
+
/** Minutes until the ticket was fully resolved, counting all reopens. */
|
|
343
612
|
full_resolution_time_in_minutes: ITimeInMinutes;
|
|
613
|
+
/** The number of groups the ticket has been assigned to. */
|
|
344
614
|
group_stations: number;
|
|
615
|
+
/** The id of the metric record. */
|
|
345
616
|
id: number;
|
|
617
|
+
/** When the ticket was first assigned (ISO 8601). */
|
|
346
618
|
initially_assigned_at: string;
|
|
619
|
+
/** When the latest comment was added (ISO 8601). */
|
|
347
620
|
latest_comment_added_at: string;
|
|
621
|
+
/** Minutes the ticket spent on hold. */
|
|
348
622
|
on_hold_time_in_minutes: ITimeInMinutes;
|
|
623
|
+
/** The number of times the ticket was reopened. */
|
|
349
624
|
reopens: number;
|
|
625
|
+
/** The number of public replies added to the ticket. */
|
|
350
626
|
replies: number;
|
|
627
|
+
/** Minutes until the first reply. */
|
|
351
628
|
reply_time_in_minutes: ITimeInMinutes;
|
|
629
|
+
/** Time until the first reply, in seconds. */
|
|
352
630
|
reply_time_in_seconds: {
|
|
631
|
+
/** Elapsed calendar time in seconds. */
|
|
353
632
|
calendar: number;
|
|
354
633
|
};
|
|
634
|
+
/** When the requester last updated the ticket (ISO 8601). */
|
|
355
635
|
requester_updated_at: string;
|
|
636
|
+
/** Minutes the requester waited on the ticket. */
|
|
356
637
|
requester_wait_time_in_minutes: ITimeInMinutes;
|
|
638
|
+
/** When the ticket was solved (ISO 8601). */
|
|
357
639
|
solved_at: string;
|
|
640
|
+
/** When the ticket's status last changed (ISO 8601). */
|
|
358
641
|
status_updated_at: string;
|
|
642
|
+
/** The id of the ticket the metrics belong to. */
|
|
359
643
|
ticket_id: number;
|
|
644
|
+
/** When the metric record was last updated (ISO 8601). */
|
|
360
645
|
updated_at: string;
|
|
361
646
|
}
|
|
647
|
+
/** Fixture for a ticket's metrics record, for use in tests. */
|
|
362
648
|
export declare const mockTicketMetric: ITicketMetric;
|
|
649
|
+
/** Builds the tickets resource of the Zendesk API (`/api/v2/tickets`) on top of a REST client; `list` includes custom statuses. */
|
|
363
650
|
declare function tickets(rest: RestClient): {
|
|
364
651
|
list: (params?: Record<string, string>) => Promise<TTicketsResponse>;
|
|
365
652
|
get: (id: number) => Promise<TTicketResponse>;
|
|
@@ -367,12 +654,19 @@ declare function tickets(rest: RestClient): {
|
|
|
367
654
|
update: (id: number, data: Partial<ITicket>) => Promise<TTicketResponse>;
|
|
368
655
|
delete: (id: number) => Promise<void>;
|
|
369
656
|
};
|
|
657
|
+
/** Fixture for a ticket's `via` object, for use in tests. */
|
|
370
658
|
export declare const mockVia: IVia;
|
|
659
|
+
/** Fixture for a ticket's metadata, for use in tests. */
|
|
371
660
|
export declare const mockMetadata: IMetadata;
|
|
661
|
+
/** Fixture for a ticket, for use in tests. */
|
|
372
662
|
export declare const mockTicket: ITicket;
|
|
663
|
+
/** Fixture for a list-of-tickets response, for use in tests. */
|
|
373
664
|
export declare const mockTicketsResponse: TTicketsResponse;
|
|
665
|
+
/** Fixture for a single ticket response, for use in tests. */
|
|
374
666
|
export declare const mockTicketResponse: TTicketResponse;
|
|
667
|
+
/** Fixture for a Zendesk user, for use in tests. */
|
|
375
668
|
export declare const mockUser: IUser;
|
|
669
|
+
/** Creates a Zendesk client with the `activities`, `comments`, `fields`, `search`, `status` and `tickets` resources, all sharing one REST client built from `opts`. */
|
|
376
670
|
export declare function createZendeskClient(opts: ZendeskClientOptions): {
|
|
377
671
|
activities: {
|
|
378
672
|
get: (params?: Record<string, string>) => Promise<IActivityResponse>;
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { createRestClient } from "@theholocron/http-client";
|
|
2
2
|
// src/activities/activities.ts
|
|
3
3
|
const PATH$5 = "/api/v2/activities";
|
|
4
|
+
/** Builds the activities resource of the Zendesk API (`/api/v2/activities`) on top of a REST client. */
|
|
4
5
|
function activities(rest) {
|
|
5
6
|
return { get: (params) => rest.request(PATH$5, { query: params }) };
|
|
6
7
|
}
|
|
7
8
|
// src/search/search.ts
|
|
8
9
|
const PATH$4 = "/api/v2/search";
|
|
10
|
+
/** Builds the search resource of the Zendesk API (`/api/v2/search`) on top of a REST client; `query` sorts descending by default. */
|
|
9
11
|
function search(rest) {
|
|
10
12
|
return { query: (q, params) => rest.request(PATH$4, { query: {
|
|
11
13
|
query: q,
|
|
@@ -15,6 +17,7 @@ function search(rest) {
|
|
|
15
17
|
}
|
|
16
18
|
// src/status/status.ts
|
|
17
19
|
const PATH$3 = "/api/v2/custom_statuses";
|
|
20
|
+
/** Builds the custom ticket statuses resource of the Zendesk API (`/api/v2/custom_statuses`) on top of a REST client. */
|
|
18
21
|
function status(rest) {
|
|
19
22
|
return {
|
|
20
23
|
list: () => rest.request(PATH$3),
|
|
@@ -31,6 +34,7 @@ function status(rest) {
|
|
|
31
34
|
}
|
|
32
35
|
// src/tickets/comments.ts
|
|
33
36
|
const PATH$2 = "/api/v2/tickets";
|
|
37
|
+
/** Builds the ticket comments resource of the Zendesk API (`/api/v2/tickets/{id}/comments`) on top of a REST client. */
|
|
34
38
|
function comments(rest) {
|
|
35
39
|
return {
|
|
36
40
|
list: (ticketId) => rest.request(`${PATH$2}/${ticketId}/comments`),
|
|
@@ -42,6 +46,7 @@ function comments(rest) {
|
|
|
42
46
|
}
|
|
43
47
|
// src/tickets/fields.ts
|
|
44
48
|
const PATH$1 = "/api/v2/ticket_fields";
|
|
49
|
+
/** Builds the ticket fields resource of the Zendesk API (`/api/v2/ticket_fields`) on top of a REST client. */
|
|
45
50
|
function fields(rest) {
|
|
46
51
|
return {
|
|
47
52
|
list: () => rest.request(PATH$1),
|
|
@@ -62,6 +67,7 @@ function fields(rest) {
|
|
|
62
67
|
}
|
|
63
68
|
// src/tickets/tickets.ts
|
|
64
69
|
const PATH = "/api/v2/tickets";
|
|
70
|
+
/** Builds the tickets resource of the Zendesk API (`/api/v2/tickets`) on top of a REST client; `list` includes custom statuses. */
|
|
65
71
|
function tickets(rest) {
|
|
66
72
|
return {
|
|
67
73
|
list: (params) => rest.request(PATH, { query: {
|
|
@@ -84,6 +90,7 @@ function tickets(rest) {
|
|
|
84
90
|
};
|
|
85
91
|
}
|
|
86
92
|
// src/utils.ts
|
|
93
|
+
/** Encodes a Zendesk API token credential as base64 `user/token:password`, the value the `token` option expects. */
|
|
87
94
|
const createToken = (user, password) => Buffer.from(`${user}/token:${password}`).toString("base64");
|
|
88
95
|
function createZendeskRestClient(opts) {
|
|
89
96
|
return createRestClient({
|
|
@@ -96,6 +103,7 @@ function createZendeskRestClient(opts) {
|
|
|
96
103
|
});
|
|
97
104
|
}
|
|
98
105
|
// src/attachments/attachments.mocks.ts
|
|
106
|
+
/** Fixture for an image record, for use in tests. */
|
|
99
107
|
const mockImage = {
|
|
100
108
|
content_type: "image/gif",
|
|
101
109
|
content_url: "https://example.zendesk.com/system/photos/8730791/1f84950b8d7949b3.gif",
|
|
@@ -109,6 +117,7 @@ const mockImage = {
|
|
|
109
117
|
url: "https://example.zendesk.com/api/v2/attachments/8730791.json",
|
|
110
118
|
width: 80
|
|
111
119
|
};
|
|
120
|
+
/** Fixture for an attachment thumbnail image, for use in tests. */
|
|
112
121
|
const mockThumbnail = {
|
|
113
122
|
content_type: "image/gif",
|
|
114
123
|
content_url: "https://example.zendesk.com/system/photos/8730801/1f84950b8d7949b3_thumb.gif",
|
|
@@ -122,11 +131,13 @@ const mockThumbnail = {
|
|
|
122
131
|
url: "https://example.zendesk.com/api/v2/attachments/8730801.json",
|
|
123
132
|
width: 32
|
|
124
133
|
};
|
|
134
|
+
/** Fixture for an attachment that carries a thumbnail, for use in tests. */
|
|
125
135
|
const mockAttachment = {
|
|
126
136
|
...mockImage,
|
|
127
137
|
thumbnails: [mockThumbnail]
|
|
128
138
|
};
|
|
129
139
|
// src/user/user.mocks.ts
|
|
140
|
+
/** Fixture for a Zendesk user, for use in tests. */
|
|
130
141
|
const mockUser = {
|
|
131
142
|
active: true,
|
|
132
143
|
alias: "test",
|
|
@@ -171,6 +182,7 @@ const mockUser = {
|
|
|
171
182
|
verified: true
|
|
172
183
|
};
|
|
173
184
|
// src/activities/activities.mocks.ts
|
|
185
|
+
/** Fixture for a single ticket activity, for use in tests. */
|
|
174
186
|
const mockActivity = {
|
|
175
187
|
actor: mockUser,
|
|
176
188
|
actor_id: 158488612,
|
|
@@ -191,6 +203,7 @@ const mockActivity = {
|
|
|
191
203
|
user_id: 3343,
|
|
192
204
|
verb: "tickets.assignment"
|
|
193
205
|
};
|
|
206
|
+
/** Fixture for a Zendesk activities list response containing `mockActivity`. */
|
|
194
207
|
const mockActivityResponse = {
|
|
195
208
|
activities: [mockActivity],
|
|
196
209
|
actors: [mockUser],
|
|
@@ -200,6 +213,7 @@ const mockActivityResponse = {
|
|
|
200
213
|
users: [mockUser]
|
|
201
214
|
};
|
|
202
215
|
// src/group/group.mocks.ts
|
|
216
|
+
/** Fixture for a Zendesk group, for use in tests. */
|
|
203
217
|
const mockGroup = {
|
|
204
218
|
created_at: "2018-04-06T03:17:05Z",
|
|
205
219
|
default: false,
|
|
@@ -211,15 +225,19 @@ const mockGroup = {
|
|
|
211
225
|
url: "https://example.zendesk.com/api/v2/groups/1835972.json"
|
|
212
226
|
};
|
|
213
227
|
// src/tickets/fields.mocks.ts
|
|
228
|
+
/** Fixture for a first custom field value on a ticket, for use in tests. */
|
|
214
229
|
const mockCustomField1 = {
|
|
215
230
|
id: 27642,
|
|
216
231
|
value: "745"
|
|
217
232
|
};
|
|
233
|
+
/** Fixture for a second custom field value on a ticket, for use in tests. */
|
|
218
234
|
const mockCustomField2 = {
|
|
219
235
|
id: 27648,
|
|
220
236
|
value: "yes"
|
|
221
237
|
};
|
|
238
|
+
/** Fixture for a list of custom field values, for use in tests. */
|
|
222
239
|
const mockCustomFields = [mockCustomField1, mockCustomField2];
|
|
240
|
+
/** Fixture for a ticket field definition, for use in tests. */
|
|
223
241
|
const mockTicketField = {
|
|
224
242
|
active: true,
|
|
225
243
|
agent_description: "Agent only description",
|
|
@@ -243,15 +261,18 @@ const mockTicketField = {
|
|
|
243
261
|
url: "https://company.zendesk.com/api/v2/ticket_fields/34.json",
|
|
244
262
|
visible_in_portal: true
|
|
245
263
|
};
|
|
264
|
+
/** Fixture for a list-of-ticket-fields response, for use in tests. */
|
|
246
265
|
const mockTicketFieldsResponse = {
|
|
247
266
|
count: 1,
|
|
248
267
|
ticket_fields: [mockTicketField]
|
|
249
268
|
};
|
|
269
|
+
/** Fixture for a single ticket field response, for use in tests. */
|
|
250
270
|
const mockTicketFieldResponse = {
|
|
251
271
|
count: 1,
|
|
252
272
|
ticket_field: mockTicketField
|
|
253
273
|
};
|
|
254
274
|
// src/tickets/tickets.mocks.ts
|
|
275
|
+
/** Fixture for a ticket's `via` object, for use in tests. */
|
|
255
276
|
const mockVia = {
|
|
256
277
|
channel: "web",
|
|
257
278
|
source: {
|
|
@@ -260,6 +281,7 @@ const mockVia = {
|
|
|
260
281
|
to: {}
|
|
261
282
|
}
|
|
262
283
|
};
|
|
284
|
+
/** Fixture for a ticket's metadata, for use in tests. */
|
|
263
285
|
const mockMetadata = {
|
|
264
286
|
system: {
|
|
265
287
|
client: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36",
|
|
@@ -270,6 +292,7 @@ const mockMetadata = {
|
|
|
270
292
|
},
|
|
271
293
|
via: mockVia
|
|
272
294
|
};
|
|
295
|
+
/** Fixture for a ticket, for use in tests. */
|
|
273
296
|
const mockTicket = {
|
|
274
297
|
assignee_id: 235323,
|
|
275
298
|
collaborator_ids: [35334, 234],
|
|
@@ -305,31 +328,37 @@ const mockTicket = {
|
|
|
305
328
|
url: "https://company.zendesk.com/api/v2/tickets/35436.json",
|
|
306
329
|
via: mockVia
|
|
307
330
|
};
|
|
331
|
+
/** Fixture for a list-of-tickets response, for use in tests. */
|
|
308
332
|
const mockTicketsResponse = {
|
|
309
333
|
count: 1,
|
|
310
334
|
tickets: [mockTicket]
|
|
311
335
|
};
|
|
336
|
+
/** Fixture for a single ticket response, for use in tests. */
|
|
312
337
|
const mockTicketResponse = {
|
|
313
338
|
count: 1,
|
|
314
339
|
ticket: mockTicket
|
|
315
340
|
};
|
|
316
341
|
// src/search/search.mocks.ts
|
|
342
|
+
/** Fixture for a search response whose results are groups. */
|
|
317
343
|
const mockSearchResponseGroups = {
|
|
318
344
|
count: 1,
|
|
319
345
|
facets: null,
|
|
320
346
|
results: [mockGroup]
|
|
321
347
|
};
|
|
348
|
+
/** Fixture for a search response whose results are tickets. */
|
|
322
349
|
const mockSearchResponseTickets = {
|
|
323
350
|
count: 1,
|
|
324
351
|
facets: null,
|
|
325
352
|
results: [mockTicket]
|
|
326
353
|
};
|
|
354
|
+
/** Fixture for a search response whose results are users. */
|
|
327
355
|
const mockSearchResponseUsers = {
|
|
328
356
|
count: 1,
|
|
329
357
|
facets: null,
|
|
330
358
|
results: [mockUser]
|
|
331
359
|
};
|
|
332
360
|
// src/status/status.mocks.ts
|
|
361
|
+
/** Fixture for a default (system) ticket status, for use in tests. */
|
|
333
362
|
const mockDefaultStatus = {
|
|
334
363
|
active: true,
|
|
335
364
|
agent_label: "open",
|
|
@@ -338,6 +367,7 @@ const mockDefaultStatus = {
|
|
|
338
367
|
end_user_label: "open",
|
|
339
368
|
status_category: "open"
|
|
340
369
|
};
|
|
370
|
+
/** Fixture for a custom ticket status, for use in tests. */
|
|
341
371
|
const mockCustomStatus = {
|
|
342
372
|
active: true,
|
|
343
373
|
agent_label: "Responding quickly",
|
|
@@ -354,15 +384,18 @@ const mockCustomStatus = {
|
|
|
354
384
|
status_category: "open",
|
|
355
385
|
updated_at: "2021-07-20T22:55:29Z"
|
|
356
386
|
};
|
|
387
|
+
/** Fixture for a list-of-custom-statuses response, for use in tests. */
|
|
357
388
|
const mockCustomStatusesResponse = {
|
|
358
389
|
count: 1,
|
|
359
390
|
custom_statuses: [mockCustomStatus]
|
|
360
391
|
};
|
|
392
|
+
/** Fixture for a single custom status response, for use in tests. */
|
|
361
393
|
const mockCustomStatusResponse = {
|
|
362
394
|
count: 1,
|
|
363
395
|
custom_status: mockCustomStatus
|
|
364
396
|
};
|
|
365
397
|
// src/tickets/comments.mocks.ts
|
|
398
|
+
/** Fixture for a ticket comment, for use in tests. */
|
|
366
399
|
const mockComment = {
|
|
367
400
|
attachments: [mockAttachment],
|
|
368
401
|
audit_id: 432567,
|
|
@@ -374,8 +407,10 @@ const mockComment = {
|
|
|
374
407
|
public: true,
|
|
375
408
|
type: "Comment"
|
|
376
409
|
};
|
|
410
|
+
/** Fixture for a ticket comments response, for use in tests. */
|
|
377
411
|
const mockCommentResponse = { comments: [mockComment] };
|
|
378
412
|
// src/tickets/metrics.mocks.ts
|
|
413
|
+
/** Fixture for a ticket's metrics record, for use in tests. */
|
|
379
414
|
const mockTicketMetric = {
|
|
380
415
|
agent_wait_time_in_minutes: {
|
|
381
416
|
business: 737,
|
|
@@ -420,6 +455,7 @@ const mockTicketMetric = {
|
|
|
420
455
|
updated_at: "2011-05-05T10:38:52Z"
|
|
421
456
|
};
|
|
422
457
|
// src/index.ts
|
|
458
|
+
/** Creates a Zendesk client with the `activities`, `comments`, `fields`, `search`, `status` and `tickets` resources, all sharing one REST client built from `opts`. */
|
|
423
459
|
function createZendeskClient(opts) {
|
|
424
460
|
const rest = createZendeskRestClient(opts);
|
|
425
461
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/zendesk-client",
|
|
3
|
-
"version": "1.58.0-alpha.
|
|
3
|
+
"version": "1.58.0-alpha.31",
|
|
4
4
|
"description": "A TypeScript client for the Zendesk API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"zendesk",
|
|
@@ -32,23 +32,23 @@
|
|
|
32
32
|
"dist"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@theholocron/http-client": "^1.58.0-alpha.
|
|
36
|
-
"@theholocron/observability": "^0.
|
|
35
|
+
"@theholocron/http-client": "^1.58.0-alpha.31",
|
|
36
|
+
"@theholocron/observability": "^0.7.0-alpha.4"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/node": "^26",
|
|
40
|
-
"@vitest/coverage-v8": "^5.0
|
|
41
|
-
"@vitest/eslint-plugin": "^1.6.
|
|
42
|
-
"eslint": "^10.
|
|
43
|
-
"eslint-plugin-n": "^18.
|
|
44
|
-
"globals": "^17.
|
|
45
|
-
"tsdown": "^0.23.
|
|
40
|
+
"@vitest/coverage-v8": "^5.1.0",
|
|
41
|
+
"@vitest/eslint-plugin": "^1.6.28",
|
|
42
|
+
"eslint": "^10.14.0",
|
|
43
|
+
"eslint-plugin-n": "^18.5.0",
|
|
44
|
+
"globals": "^17.14.0",
|
|
45
|
+
"tsdown": "^0.23.5",
|
|
46
46
|
"typescript": "^5.9.3",
|
|
47
|
-
"vitest": "^5.0
|
|
48
|
-
"@theholocron/
|
|
49
|
-
"@theholocron/tsdown-config": "^8.9.0-alpha.
|
|
50
|
-
"@theholocron/
|
|
51
|
-
"@theholocron/
|
|
47
|
+
"vitest": "^5.1.0",
|
|
48
|
+
"@theholocron/tsconfig": "^8.9.0-alpha.17",
|
|
49
|
+
"@theholocron/tsdown-config": "^8.9.0-alpha.17",
|
|
50
|
+
"@theholocron/vitest-config": "^8.9.0-alpha.17",
|
|
51
|
+
"@theholocron/eslint-config": "^8.9.0-alpha.17"
|
|
52
52
|
},
|
|
53
53
|
"engines": {
|
|
54
54
|
"node": ">=22.0.0"
|
|
@@ -57,10 +57,10 @@
|
|
|
57
57
|
"access": "public"
|
|
58
58
|
},
|
|
59
59
|
"scripts": {
|
|
60
|
-
"
|
|
61
|
-
"
|
|
60
|
+
"build": "tsdown && node ../scripts/check-bundle-size.mjs",
|
|
61
|
+
"lint:code": "eslint .",
|
|
62
|
+
"test:unit": "vitest run --coverage",
|
|
62
63
|
"test:watch": "vitest",
|
|
63
|
-
"
|
|
64
|
-
"verification.unitTests": "vitest run"
|
|
64
|
+
"typecheck": "tsc --noEmit"
|
|
65
65
|
}
|
|
66
66
|
}
|