@theholocron/zendesk-client 1.31.0 → 1.32.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/zendesk-client",
3
- "version": "1.31.0",
3
+ "version": "1.32.0",
4
4
  "description": "A TypeScript client for the Zendesk API",
5
5
  "keywords": [
6
6
  "zendesk",
@@ -33,13 +33,13 @@
33
33
  ],
34
34
  "dependencies": {
35
35
  "@theholocron/observability": "^0.3.0",
36
- "@theholocron/http-client": "^1.31.0"
36
+ "@theholocron/http-client": "^1.32.0"
37
37
  },
38
38
  "devDependencies": {
39
- "@theholocron/cli": "5.0.0-alpha.33",
39
+ "@theholocron/cli": "5.0.0-alpha.79",
40
40
  "@theholocron/eslint-config": "^8.4.3",
41
41
  "@theholocron/tsconfig": "^8.2.0",
42
- "@theholocron/tsdown-config": "^8.2.0",
42
+ "@theholocron/tsdown-config": "^8.5.2",
43
43
  "@theholocron/vitest-config": "^8.2.0",
44
44
  "@types/node": "^26.4.1",
45
45
  "@vitest/coverage-v8": "^5.0.0",
@@ -61,7 +61,7 @@
61
61
  "releases": "https://github.com/theholocron/clients/releases",
62
62
  "wiki": "https://github.com/theholocron/clients/wiki",
63
63
  "scripts": {
64
- "delivery.build": "tsdown",
64
+ "delivery.build": "holocron run delivery.build -- && node ../../scripts/check-bundle-size.mjs",
65
65
  "sourceQuality.staticAnalysis": "holocron run sourceQuality.staticAnalysis --",
66
66
  "test:watch": "vitest",
67
67
  "verification.typeSafety": "holocron run verification.typeSafety --",
package/dist/index.d.mts DELETED
@@ -1,466 +0,0 @@
1
- import { RestClient } from "@theholocron/http-client";
2
- import { ErrorSink, Logger } from "@theholocron/observability/core";
3
- //#region src/types.d.ts
4
- interface IAPIResponse {
5
- next_page?: string | null;
6
- previous_page?: string | null;
7
- count: number;
8
- }
9
- interface IAPIError {
10
- error: string;
11
- description: string;
12
- }
13
- //#endregion
14
- //#region src/attachments/attachments.types.d.ts
15
- interface IImage {
16
- content_type?: string | null;
17
- content_url?: string | null;
18
- deleted?: boolean | null;
19
- file_name?: string | null;
20
- height?: number | null;
21
- id?: number | null;
22
- inline?: boolean | null;
23
- malware_access_override?: boolean | null;
24
- malware_scan_result?: "malware_found" | "malware_not_found" | "failed_to_scan" | "not_scanned" | null;
25
- mapped_content_url?: string | null;
26
- size?: number | null;
27
- url?: string | null;
28
- width?: number | null;
29
- }
30
- interface IAttachment extends IImage {
31
- thumbnails?: IImage[];
32
- }
33
- //#endregion
34
- //#region src/attachments/attachments.mocks.d.ts
35
- declare const mockImage: IImage;
36
- declare const mockThumbnail: IImage;
37
- declare const mockAttachment: IAttachment;
38
- //#endregion
39
- //#region src/user/user.types.d.ts
40
- interface IUser {
41
- active?: boolean | null;
42
- alias?: string | null;
43
- chat_only?: boolean | null;
44
- created_at?: string | null;
45
- custom_role_id?: number | null;
46
- default_group_id?: number | null;
47
- details?: string | null;
48
- email?: string | null;
49
- external_id?: string | null;
50
- iana_time_zone?: string | null;
51
- id?: number | null;
52
- last_login_at?: string | null;
53
- locale?: string | null;
54
- locale_id?: number | null;
55
- moderator?: boolean | null;
56
- name: string | null;
57
- notes?: string | null;
58
- only_private_comments?: boolean | null;
59
- organization_id?: number | null;
60
- phone?: string | null;
61
- photo?: IAttachment | null;
62
- remote_photo_url?: string | null;
63
- report_csv?: boolean | null;
64
- restricted_agent?: boolean | null;
65
- role?: "end-user" | "agent" | "admin" | null;
66
- role_type?: 0 | 1 | 2 | 3 | 4 | 5 | null;
67
- shared?: boolean | null;
68
- shared_agent?: boolean | null;
69
- shared_phone_number?: boolean | null;
70
- signature?: string | null;
71
- suspended?: boolean | null;
72
- tags?: string[] | null;
73
- ticket_restriction?: "organization" | "groups" | "assigned" | "requested" | null;
74
- time_zone?: string | null;
75
- two_factor_auth_enabled?: boolean | null;
76
- updated_at?: string | null;
77
- url?: string | null;
78
- user_fields?: Record<string, unknown> | null;
79
- verified?: boolean | null;
80
- }
81
- //#endregion
82
- //#region src/activities/activities.types.d.ts
83
- interface IActivity {
84
- actor?: IUser | null;
85
- actor_id?: number | null;
86
- created_at?: string | null;
87
- id?: number | null;
88
- object?: Record<string, unknown> | null;
89
- target?: Record<string, unknown> | null;
90
- title?: string | null;
91
- updated_at?: string | null;
92
- url?: string | null;
93
- user?: IUser | null;
94
- user_id?: number | null;
95
- verb?: "tickets.assignment" | "tickets.comment" | "tickets.priority_increase" | null;
96
- }
97
- interface IActivityResponse extends IAPIResponse {
98
- activities: IActivity[];
99
- actors: IUser[];
100
- users: IUser[];
101
- }
102
- //#endregion
103
- //#region src/tickets/fields.types.d.ts
104
- interface ICustomField {
105
- id: number | null;
106
- value: string | number | string[] | null;
107
- }
108
- interface ITicketField {
109
- active?: boolean | null;
110
- agent_description?: string | null;
111
- collapsed_for_agents?: boolean | null;
112
- created_at?: string | null;
113
- custom_field_options?: Array<unknown> | null;
114
- custom_statuses?: Array<unknown> | null;
115
- description?: string | null;
116
- editable_in_portal?: boolean | null;
117
- id?: number | null;
118
- position?: number | null;
119
- raw_description?: string | null;
120
- raw_title?: string | null;
121
- raw_title_in_portal?: string | null;
122
- regexp_for_validation?: string | null;
123
- relationship_filter?: Record<string, unknown> | null;
124
- relationship_target_type?: string | null;
125
- removable?: boolean | null;
126
- required?: boolean | null;
127
- required_in_portal?: boolean | null;
128
- sub_type_id?: number | null;
129
- system_field_options?: Array<unknown> | null;
130
- tag?: string | null;
131
- title: string | null;
132
- title_in_portal?: string | null;
133
- type: string | null;
134
- updated_at?: string | null;
135
- url?: string | null;
136
- visible_in_portal?: boolean | null;
137
- }
138
- type TTicketFieldsResponse = IAPIResponse & {
139
- ticket_fields: ITicketField[];
140
- };
141
- type TTicketFieldResponse = IAPIResponse & {
142
- ticket_field: ITicketField;
143
- };
144
- //#endregion
145
- //#region src/tickets/tickets.types.d.ts
146
- type TTicketStatus = "new" | "open" | "pending" | "hold" | "solved" | "closed";
147
- type TTicketPriority = "urgent" | "high" | "normal" | "low";
148
- type TTicketType = "problem" | "incident" | "question" | "task";
149
- interface IVia {
150
- channel: string | number | null;
151
- source?: {
152
- from?: Record<string, unknown>;
153
- rel?: string | null;
154
- to?: Record<string, unknown>;
155
- };
156
- }
157
- interface IMetadata {
158
- system?: {
159
- client?: string | null;
160
- ip_address?: string | null;
161
- latitude?: number | null;
162
- location?: string | null;
163
- longitude?: number | null;
164
- };
165
- via: IVia;
166
- }
167
- interface ITicket {
168
- allow_attachments?: boolean | null;
169
- allow_channelback?: boolean | null;
170
- assignee_email?: string | null;
171
- assignee_id?: number | null;
172
- attribute_value_ids?: string[] | null;
173
- brand_id?: number | null;
174
- collaborator_ids?: number[] | null;
175
- collaborators?: Array<unknown> | null;
176
- comment?: IComment | null;
177
- created_at?: string | null;
178
- custom_fields?: ICustomField[] | null;
179
- custom_status_id?: number | null;
180
- description?: string | null;
181
- due_at?: string | null;
182
- email_cc_ids?: number[] | null;
183
- email_ccs?: Array<Record<string, unknown>>;
184
- external_id?: string | null;
185
- follower_ids?: number[] | null;
186
- followers?: Array<Record<string, unknown>>;
187
- followup_ids?: number[] | null;
188
- forum_topic_id?: number | null;
189
- from_messaging_channel?: boolean | null;
190
- group_id?: number | null;
191
- has_incidents?: boolean | null;
192
- id?: number | null;
193
- is_public?: boolean | null;
194
- macro_id?: number | null;
195
- macro_ids?: number[] | null;
196
- metadata?: IMetadata | null;
197
- organization_id?: number | null;
198
- priority?: TTicketPriority | null;
199
- problem_id?: number | null;
200
- raw_subject?: string | null;
201
- recipient?: string | null;
202
- requester?: Record<string, unknown>;
203
- requester_id: number | null;
204
- safe_update?: boolean | null;
205
- satisfaction_rating?: Record<string, unknown>;
206
- sharing_agreement_ids?: number[] | null;
207
- status?: TTicketStatus | null;
208
- subject?: string | null;
209
- submitter_id?: number | null;
210
- tags?: string[] | null;
211
- ticket_form_id?: number | null;
212
- type?: TTicketType | null;
213
- updated_at?: string | null;
214
- updated_stamp?: string | null;
215
- url?: string | null;
216
- via?: IVia | null;
217
- via_followup_source_id?: number | null;
218
- via_id?: number | null;
219
- voice_comment?: Record<string, unknown>;
220
- }
221
- type TTicketsResponse = IAPIResponse & {
222
- tickets: ITicket[];
223
- deleted_ticket_forms?: Array<unknown>;
224
- };
225
- type TTicketResponse = IAPIResponse & {
226
- ticket: ITicket;
227
- deleted_ticket_forms?: Array<unknown>;
228
- };
229
- //#endregion
230
- //#region src/tickets/comments.types.d.ts
231
- interface IComment {
232
- attachments?: IAttachment[] | null;
233
- audit_id?: number | null;
234
- author_id?: number | null;
235
- body?: string | null;
236
- created_at?: string | null;
237
- html_body?: string | null;
238
- id?: number | null;
239
- metadata?: IMetadata | null;
240
- plain_body?: string | null;
241
- public?: boolean | null;
242
- type?: "Comment" | "VoiceComment" | null;
243
- uploads?: string[] | null;
244
- via?: IVia | null;
245
- }
246
- interface ICommentResponse {
247
- comments: IComment[];
248
- }
249
- //#endregion
250
- //#region src/group/group.types.d.ts
251
- interface IGroup {
252
- created_at?: string | null;
253
- default?: boolean | null;
254
- deleted?: boolean | null;
255
- description?: string | null;
256
- id?: number | null;
257
- is_public?: boolean | null;
258
- name?: string | null;
259
- updated_at?: string | null;
260
- url?: string | null;
261
- }
262
- //#endregion
263
- //#region src/search/search.types.d.ts
264
- interface ISearchResponse extends IAPIResponse {
265
- facets?: string | null;
266
- results: ITicket[] | IUser[] | IGroup[];
267
- }
268
- //#endregion
269
- //#region src/status/status.types.d.ts
270
- interface IStatus {
271
- active?: boolean | null;
272
- agent_label?: string | null;
273
- description?: string | null;
274
- end_user_description?: string | null;
275
- status_category?: string | null;
276
- }
277
- interface IDefaultStatus extends IStatus {
278
- end_user_label?: "new" | "open" | "pending" | "hold" | "solved" | null;
279
- }
280
- interface ICustomStatus extends IStatus {
281
- created_at?: string | null;
282
- default?: boolean | null;
283
- end_user_label?: string | null;
284
- id?: number | null;
285
- raw_agent_label?: string | null;
286
- raw_description?: string | null;
287
- raw_end_user_description?: string | null;
288
- raw_end_user_label?: string | null;
289
- updated_at?: string | null;
290
- url?: string | null;
291
- }
292
- interface ICustomStatusesResponse extends IAPIResponse {
293
- custom_statuses: ICustomStatus[];
294
- }
295
- interface ICustomStatusResponse extends IAPIResponse {
296
- custom_status: ICustomStatus;
297
- }
298
- //#endregion
299
- //#region src/utils.d.ts
300
- declare const createToken: (user: string, password: string) => string;
301
- interface ZendeskClientOptions {
302
- /** Base URL of your Zendesk instance, e.g. "https://myorg.zendesk.com". */
303
- baseUrl: string;
304
- /** Token from createToken(email, apiToken). */
305
- token: string;
306
- /** Override fetch for testing. Defaults to globalThis.fetch. */
307
- fetch?: typeof fetch;
308
- /** Structured logger for request/response diagnostics. Defaults to a no-op. */
309
- logger?: Logger;
310
- /** Reports transport failures and unexpected 5xx. Defaults to a no-op. */
311
- errors?: ErrorSink;
312
- }
313
- //#endregion
314
- //#region src/activities/activities.d.ts
315
- declare function activities(rest: RestClient): {
316
- get: (params?: Record<string, string>) => Promise<IActivityResponse>;
317
- };
318
- //#endregion
319
- //#region src/activities/activities.mocks.d.ts
320
- declare const mockActivity: IActivity;
321
- declare const mockActivityResponse: IActivityResponse;
322
- //#endregion
323
- //#region src/group/group.mocks.d.ts
324
- declare const mockGroup: IGroup;
325
- //#endregion
326
- //#region src/search/search.d.ts
327
- declare function search(rest: RestClient): {
328
- query: (q: string, params?: Record<string, string>) => Promise<ISearchResponse>;
329
- };
330
- //#endregion
331
- //#region src/search/search.mocks.d.ts
332
- declare const mockSearchResponseGroups: ISearchResponse;
333
- declare const mockSearchResponseTickets: ISearchResponse;
334
- declare const mockSearchResponseUsers: ISearchResponse;
335
- //#endregion
336
- //#region src/status/status.d.ts
337
- declare function status(rest: RestClient): {
338
- list: () => Promise<ICustomStatusesResponse>;
339
- get: (id: number) => Promise<ICustomStatusResponse>;
340
- create: (data: ICustomStatus) => Promise<ICustomStatusResponse>;
341
- update: (id: number, data: Partial<ICustomStatus>) => Promise<ICustomStatusResponse>;
342
- };
343
- //#endregion
344
- //#region src/status/status.mocks.d.ts
345
- declare const mockDefaultStatus: IDefaultStatus;
346
- declare const mockCustomStatus: ICustomStatus;
347
- declare const mockCustomStatusesResponse: ICustomStatusesResponse;
348
- declare const mockCustomStatusResponse: ICustomStatusResponse;
349
- //#endregion
350
- //#region src/tickets/comments.d.ts
351
- declare function comments(rest: RestClient): {
352
- list: (ticketId: number) => Promise<ICommentResponse>;
353
- create: (ticketId: number, body: string) => Promise<void>;
354
- };
355
- //#endregion
356
- //#region src/tickets/comments.mocks.d.ts
357
- declare const mockComment: IComment;
358
- declare const mockCommentResponse: ICommentResponse;
359
- //#endregion
360
- //#region src/tickets/fields.d.ts
361
- declare function fields(rest: RestClient): {
362
- list: () => Promise<TTicketFieldsResponse>;
363
- get: (id: number) => Promise<TTicketFieldResponse>;
364
- create: (data: ITicketField) => Promise<TTicketFieldResponse>;
365
- update: (id: number, data: Partial<ITicketField>) => Promise<TTicketFieldResponse>;
366
- delete: (id: number) => Promise<void>;
367
- };
368
- //#endregion
369
- //#region src/tickets/fields.mocks.d.ts
370
- declare const mockCustomField1: ICustomField;
371
- declare const mockCustomField2: ICustomField;
372
- declare const mockCustomFields: ICustomField[];
373
- declare const mockTicketField: ITicketField;
374
- declare const mockTicketFieldsResponse: TTicketFieldsResponse;
375
- declare const mockTicketFieldResponse: TTicketFieldResponse;
376
- //#endregion
377
- //#region src/tickets/metrics.types.d.ts
378
- interface ITimeInMinutes {
379
- business: number;
380
- calendar: number;
381
- }
382
- interface ITicketMetric {
383
- agent_wait_time_in_minutes: ITimeInMinutes;
384
- assigned_at: string;
385
- assignee_stations: number;
386
- assignee_updated_at: string;
387
- created_at: string;
388
- custom_status_updated_at: string;
389
- first_resolution_time_in_minutes: ITimeInMinutes;
390
- full_resolution_time_in_minutes: ITimeInMinutes;
391
- group_stations: number;
392
- id: number;
393
- initially_assigned_at: string;
394
- latest_comment_added_at: string;
395
- on_hold_time_in_minutes: ITimeInMinutes;
396
- reopens: number;
397
- replies: number;
398
- reply_time_in_minutes: ITimeInMinutes;
399
- reply_time_in_seconds: {
400
- calendar: number;
401
- };
402
- requester_updated_at: string;
403
- requester_wait_time_in_minutes: ITimeInMinutes;
404
- solved_at: string;
405
- status_updated_at: string;
406
- ticket_id: number;
407
- updated_at: string;
408
- }
409
- //#endregion
410
- //#region src/tickets/metrics.mocks.d.ts
411
- declare const mockTicketMetric: ITicketMetric;
412
- //#endregion
413
- //#region src/tickets/tickets.d.ts
414
- declare function tickets(rest: RestClient): {
415
- list: (params?: Record<string, string>) => Promise<TTicketsResponse>;
416
- get: (id: number) => Promise<TTicketResponse>;
417
- create: (data: ITicket) => Promise<TTicketResponse>;
418
- update: (id: number, data: Partial<ITicket>) => Promise<TTicketResponse>;
419
- delete: (id: number) => Promise<void>;
420
- };
421
- //#endregion
422
- //#region src/tickets/tickets.mocks.d.ts
423
- declare const mockVia: IVia;
424
- declare const mockMetadata: IMetadata;
425
- declare const mockTicket: ITicket;
426
- declare const mockTicketsResponse: TTicketsResponse;
427
- declare const mockTicketResponse: TTicketResponse;
428
- //#endregion
429
- //#region src/user/user.mocks.d.ts
430
- declare const mockUser: IUser;
431
- //#endregion
432
- //#region src/index.d.ts
433
- declare function createZendeskClient(opts: ZendeskClientOptions): {
434
- activities: {
435
- get: (params?: Record<string, string>) => Promise<IActivityResponse>;
436
- };
437
- comments: {
438
- list: (ticketId: number) => Promise<ICommentResponse>;
439
- create: (ticketId: number, body: string) => Promise<void>;
440
- };
441
- fields: {
442
- list: () => Promise<TTicketFieldsResponse>;
443
- get: (id: number) => Promise<TTicketFieldResponse>;
444
- create: (data: ITicketField) => Promise<TTicketFieldResponse>;
445
- update: (id: number, data: Partial<ITicketField>) => Promise<TTicketFieldResponse>;
446
- delete: (id: number) => Promise<void>;
447
- };
448
- search: {
449
- query: (q: string, params?: Record<string, string>) => Promise<ISearchResponse>;
450
- };
451
- status: {
452
- list: () => Promise<ICustomStatusesResponse>;
453
- get: (id: number) => Promise<ICustomStatusResponse>;
454
- create: (data: ICustomStatus) => Promise<ICustomStatusResponse>;
455
- update: (id: number, data: Partial<ICustomStatus>) => Promise<ICustomStatusResponse>;
456
- };
457
- tickets: {
458
- list: (params?: Record<string, string>) => Promise<TTicketsResponse>;
459
- get: (id: number) => Promise<TTicketResponse>;
460
- create: (data: ITicket) => Promise<TTicketResponse>;
461
- update: (id: number, data: Partial<ITicket>) => Promise<TTicketResponse>;
462
- delete: (id: number) => Promise<void>;
463
- };
464
- };
465
- //#endregion
466
- export { type IAPIError, type IAPIResponse, type IActivity, type IActivityResponse, type IAttachment, type IComment, type ICommentResponse, type ICustomField, type ICustomStatus, type ICustomStatusResponse, type ICustomStatusesResponse, type IDefaultStatus, type IGroup, type IImage, type IMetadata, type ISearchResponse, type ITicket, type ITicketField, type ITicketMetric, type IUser, type IVia, type TTicketFieldResponse, type TTicketFieldsResponse, type TTicketPriority, type TTicketResponse, type TTicketStatus, type TTicketType, type TTicketsResponse, type ZendeskClientOptions, type activities, type comments, createToken, createZendeskClient, type fields, mockActivity, mockActivityResponse, mockAttachment, mockComment, mockCommentResponse, mockCustomField1, mockCustomField2, mockCustomFields, mockCustomStatus, mockCustomStatusResponse, mockCustomStatusesResponse, mockDefaultStatus, mockGroup, mockImage, mockMetadata, mockSearchResponseGroups, mockSearchResponseTickets, mockSearchResponseUsers, mockThumbnail, mockTicket, mockTicketField, mockTicketFieldResponse, mockTicketFieldsResponse, mockTicketMetric, mockTicketResponse, mockTicketsResponse, mockUser, mockVia, type search, type status, type tickets };
package/dist/index.mjs DELETED
@@ -1,452 +0,0 @@
1
- import { createRestClient } from "@theholocron/http-client";
2
- //#region src/activities/activities.ts
3
- const PATH$5 = "/api/v2/activities";
4
- function activities(rest) {
5
- return { get: (params) => rest.request(PATH$5, { query: params }) };
6
- }
7
- //#endregion
8
- //#region src/search/search.ts
9
- const PATH$4 = "/api/v2/search";
10
- function search(rest) {
11
- return { query: (q, params) => rest.request(PATH$4, { query: {
12
- query: q,
13
- sort_order: "desc",
14
- ...params
15
- } }) };
16
- }
17
- //#endregion
18
- //#region src/status/status.ts
19
- const PATH$3 = "/api/v2/custom_statuses";
20
- function status(rest) {
21
- return {
22
- list: () => rest.request(PATH$3),
23
- get: (id) => rest.request(`${PATH$3}/${id}`),
24
- create: (data) => rest.request(PATH$3, {
25
- method: "POST",
26
- body: { custom_status: data }
27
- }),
28
- update: (id, data) => rest.request(`${PATH$3}/${id}`, {
29
- method: "PUT",
30
- body: { custom_status: data }
31
- })
32
- };
33
- }
34
- //#endregion
35
- //#region src/tickets/comments.ts
36
- const PATH$2 = "/api/v2/tickets";
37
- function comments(rest) {
38
- return {
39
- list: (ticketId) => rest.request(`${PATH$2}/${ticketId}/comments`),
40
- create: (ticketId, body) => rest.request(`${PATH$2}/${ticketId}`, {
41
- method: "PUT",
42
- body: { ticket: { comment: { body } } }
43
- })
44
- };
45
- }
46
- //#endregion
47
- //#region src/tickets/fields.ts
48
- const PATH$1 = "/api/v2/ticket_fields";
49
- function fields(rest) {
50
- return {
51
- list: () => rest.request(PATH$1),
52
- get: (id) => rest.request(`${PATH$1}/${id}`),
53
- create: (data) => rest.request(PATH$1, {
54
- method: "POST",
55
- body: { ticket_field: data }
56
- }),
57
- update: (id, data) => rest.request(`${PATH$1}/${id}`, {
58
- method: "PUT",
59
- body: { ticket_field: data }
60
- }),
61
- delete: (id) => rest.request(`${PATH$1}/${id}`, {
62
- method: "DELETE",
63
- expectNoContent: true
64
- })
65
- };
66
- }
67
- //#endregion
68
- //#region src/tickets/tickets.ts
69
- const PATH = "/api/v2/tickets";
70
- function tickets(rest) {
71
- return {
72
- list: (params) => rest.request(PATH, { query: {
73
- include: "custom_statuses",
74
- ...params
75
- } }),
76
- get: (id) => rest.request(`${PATH}/${id}`),
77
- create: (data) => rest.request(PATH, {
78
- method: "POST",
79
- body: { ticket: data }
80
- }),
81
- update: (id, data) => rest.request(`${PATH}/${id}`, {
82
- method: "PUT",
83
- body: { ticket: data }
84
- }),
85
- delete: (id) => rest.request(`${PATH}/${id}`, {
86
- method: "DELETE",
87
- expectNoContent: true
88
- })
89
- };
90
- }
91
- //#endregion
92
- //#region src/utils.ts
93
- const createToken = (user, password) => Buffer.from(`${user}/token:${password}`).toString("base64");
94
- function createZendeskRestClient(opts) {
95
- return createRestClient({
96
- baseUrl: opts.baseUrl,
97
- token: opts.token,
98
- vendor: "Zendesk",
99
- fetch: opts.fetch,
100
- logger: opts.logger,
101
- errors: opts.errors
102
- });
103
- }
104
- //#endregion
105
- //#region src/attachments/attachments.mocks.ts
106
- const mockImage = {
107
- content_type: "image/gif",
108
- content_url: "https://example.zendesk.com/system/photos/8730791/1f84950b8d7949b3.gif",
109
- deleted: false,
110
- file_name: "1f84950b8d7949b3.gif",
111
- height: 80,
112
- id: 8730791,
113
- inline: false,
114
- mapped_content_url: "https://example.zendesk.com/system/photos/8730791/1f84950b8d7949b3.gif",
115
- size: 4566,
116
- url: "https://example.zendesk.com/api/v2/attachments/8730791.json",
117
- width: 80
118
- };
119
- const mockThumbnail = {
120
- content_type: "image/gif",
121
- content_url: "https://example.zendesk.com/system/photos/8730801/1f84950b8d7949b3_thumb.gif",
122
- deleted: false,
123
- file_name: "1f84950b8d7949b3_thumb.gif",
124
- height: 32,
125
- id: 8730801,
126
- inline: false,
127
- mapped_content_url: "https://example.zendesk.com/system/photos/8730801/1f84950b8d7949b3_thumb.gif",
128
- size: 1517,
129
- url: "https://example.zendesk.com/api/v2/attachments/8730801.json",
130
- width: 32
131
- };
132
- const mockAttachment = {
133
- ...mockImage,
134
- thumbnails: [mockThumbnail]
135
- };
136
- //#endregion
137
- //#region src/user/user.mocks.ts
138
- const mockUser = {
139
- active: true,
140
- alias: "test",
141
- created_at: "2017-08-14T20:13:53Z",
142
- custom_role_id: null,
143
- default_group_id: 1873,
144
- details: "",
145
- email: "user@zendesk.com",
146
- external_id: "oev7jj",
147
- iana_time_zone: "Pacific/Pago_Pago",
148
- id: 3343,
149
- last_login_at: "2020-11-16T22:57:45Z",
150
- locale: "en-gb",
151
- locale_id: 5,
152
- moderator: true,
153
- name: "Samwise Gamgee",
154
- notes: "test",
155
- only_private_comments: false,
156
- organization_id: 1873,
157
- phone: null,
158
- photo: mockAttachment,
159
- report_csv: true,
160
- restricted_agent: false,
161
- role: "admin",
162
- role_type: null,
163
- shared: false,
164
- shared_agent: false,
165
- shared_phone_number: null,
166
- signature: "test",
167
- suspended: false,
168
- tags: ["101"],
169
- ticket_restriction: null,
170
- time_zone: "American Samoa",
171
- two_factor_auth_enabled: null,
172
- updated_at: "2020-11-17T00:33:55Z",
173
- url: "https://example.zendesk.com/api/v2/users/3343.json",
174
- user_fields: {
175
- its_remember_september: null,
176
- skittles: "2018-09-14T00:00:00+00:00",
177
- user_field_1: "101"
178
- },
179
- verified: true
180
- };
181
- //#endregion
182
- //#region src/activities/activities.mocks.ts
183
- const mockActivity = {
184
- actor: mockUser,
185
- actor_id: 158488612,
186
- created_at: "2020-11-17T00:34:40Z",
187
- id: 29183462,
188
- object: { ticket: {
189
- id: 1521,
190
- subject: "test"
191
- } },
192
- target: { ticket: {
193
- id: 1521,
194
- subject: "test"
195
- } },
196
- title: "Tedd assigned ticket #1521 to you.",
197
- updated_at: "2020-11-17T00:34:40Z",
198
- url: "https://example.zendesk.com/api/v2/activities/29183462.json",
199
- user: mockUser,
200
- user_id: 3343,
201
- verb: "tickets.assignment"
202
- };
203
- const mockActivityResponse = {
204
- activities: [mockActivity],
205
- actors: [mockUser],
206
- count: 1,
207
- next_page: null,
208
- previous_page: null,
209
- users: [mockUser]
210
- };
211
- //#endregion
212
- //#region src/group/group.mocks.ts
213
- const mockGroup = {
214
- created_at: "2018-04-06T03:17:05Z",
215
- default: false,
216
- deleted: false,
217
- description: "",
218
- id: 1835972,
219
- name: "Ragtail",
220
- updated_at: "2018-04-06T03:17:05Z",
221
- url: "https://example.zendesk.com/api/v2/groups/1835972.json"
222
- };
223
- //#endregion
224
- //#region src/tickets/fields.mocks.ts
225
- const mockCustomField1 = {
226
- id: 27642,
227
- value: "745"
228
- };
229
- const mockCustomField2 = {
230
- id: 27648,
231
- value: "yes"
232
- };
233
- const mockCustomFields = [mockCustomField1, mockCustomField2];
234
- const mockTicketField = {
235
- active: true,
236
- agent_description: "Agent only description",
237
- collapsed_for_agents: false,
238
- created_at: "2009-07-20T22:55:29Z",
239
- description: "This is the subject field of a ticket",
240
- editable_in_portal: true,
241
- id: 34,
242
- position: 21,
243
- raw_description: "This is the subject field of a ticket",
244
- raw_title: "{{dc.my_title}}",
245
- raw_title_in_portal: "{{dc.my_title_in_portal}}",
246
- regexp_for_validation: null,
247
- required: true,
248
- required_in_portal: true,
249
- tag: null,
250
- title: "Subject",
251
- title_in_portal: "Subject",
252
- type: "subject",
253
- updated_at: "2011-05-05T10:38:52Z",
254
- url: "https://company.zendesk.com/api/v2/ticket_fields/34.json",
255
- visible_in_portal: true
256
- };
257
- const mockTicketFieldsResponse = {
258
- count: 1,
259
- ticket_fields: [mockTicketField]
260
- };
261
- const mockTicketFieldResponse = {
262
- count: 1,
263
- ticket_field: mockTicketField
264
- };
265
- //#endregion
266
- //#region src/tickets/tickets.mocks.ts
267
- const mockVia = {
268
- channel: "web",
269
- source: {
270
- from: {},
271
- rel: "web_widget",
272
- to: {}
273
- }
274
- };
275
- const mockMetadata = {
276
- system: {
277
- 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",
278
- ip_address: "1.1.1.1",
279
- latitude: -37.000000000001,
280
- location: "Melbourne, 07, Australia",
281
- longitude: 144.0000000000002
282
- },
283
- via: mockVia
284
- };
285
- const mockTicket = {
286
- assignee_id: 235323,
287
- collaborator_ids: [35334, 234],
288
- created_at: "2009-07-20T22:55:29Z",
289
- custom_fields: mockCustomFields,
290
- custom_status_id: 123,
291
- description: "The fire is very colorful.",
292
- due_at: null,
293
- external_id: "ahg35h3jh",
294
- follower_ids: [35334, 234],
295
- from_messaging_channel: false,
296
- group_id: 98738,
297
- has_incidents: false,
298
- id: 35436,
299
- organization_id: 509974,
300
- priority: "high",
301
- problem_id: 9873764,
302
- raw_subject: "{{dc.printer_on_fire}}",
303
- recipient: "support@company.com",
304
- requester_id: 20978392,
305
- satisfaction_rating: {
306
- comment: "Great support!",
307
- id: 1234,
308
- score: "good"
309
- },
310
- sharing_agreement_ids: [84432],
311
- status: "open",
312
- subject: "Help, my printer is on fire!",
313
- submitter_id: 76872,
314
- tags: ["enterprise", "other_tag"],
315
- type: "incident",
316
- updated_at: "2011-05-05T10:38:52Z",
317
- url: "https://company.zendesk.com/api/v2/tickets/35436.json",
318
- via: mockVia
319
- };
320
- const mockTicketsResponse = {
321
- count: 1,
322
- tickets: [mockTicket]
323
- };
324
- const mockTicketResponse = {
325
- count: 1,
326
- ticket: mockTicket
327
- };
328
- //#endregion
329
- //#region src/search/search.mocks.ts
330
- const mockSearchResponseGroups = {
331
- count: 1,
332
- facets: null,
333
- results: [mockGroup]
334
- };
335
- const mockSearchResponseTickets = {
336
- count: 1,
337
- facets: null,
338
- results: [mockTicket]
339
- };
340
- const mockSearchResponseUsers = {
341
- count: 1,
342
- facets: null,
343
- results: [mockUser]
344
- };
345
- //#endregion
346
- //#region src/status/status.mocks.ts
347
- const mockDefaultStatus = {
348
- active: true,
349
- agent_label: "open",
350
- description: "Customer needs a response quickly",
351
- end_user_description: "Your ticket is being responded to",
352
- end_user_label: "open",
353
- status_category: "open"
354
- };
355
- const mockCustomStatus = {
356
- active: true,
357
- agent_label: "Responding quickly",
358
- created_at: "2021-07-20T22:55:29Z",
359
- default: false,
360
- description: "Customer needs a response quickly",
361
- end_user_description: "Your ticket is being responded to",
362
- end_user_label: "Urgent processing",
363
- id: 35436,
364
- raw_agent_label: "Responding quickly",
365
- raw_description: "Customer needs a response quickly",
366
- raw_end_user_description: "Your ticket is being responded to",
367
- raw_end_user_label: "Urgent processing",
368
- status_category: "open",
369
- updated_at: "2021-07-20T22:55:29Z"
370
- };
371
- const mockCustomStatusesResponse = {
372
- count: 1,
373
- custom_statuses: [mockCustomStatus]
374
- };
375
- const mockCustomStatusResponse = {
376
- count: 1,
377
- custom_status: mockCustomStatus
378
- };
379
- //#endregion
380
- //#region src/tickets/comments.mocks.ts
381
- const mockComment = {
382
- attachments: [mockAttachment],
383
- audit_id: 432567,
384
- author_id: 123123,
385
- body: "Thanks for your help!",
386
- created_at: "2009-07-20T22:55:29Z",
387
- id: 1274,
388
- metadata: mockMetadata,
389
- public: true,
390
- type: "Comment"
391
- };
392
- const mockCommentResponse = { comments: [mockComment] };
393
- //#endregion
394
- //#region src/tickets/metrics.mocks.ts
395
- const mockTicketMetric = {
396
- agent_wait_time_in_minutes: {
397
- business: 737,
398
- calendar: 2391
399
- },
400
- assigned_at: "2011-05-05T10:38:52Z",
401
- assignee_stations: 1,
402
- assignee_updated_at: "2011-05-06T10:38:52Z",
403
- created_at: "2009-07-20T22:55:29Z",
404
- custom_status_updated_at: "2011-05-09T10:38:52Z",
405
- first_resolution_time_in_minutes: {
406
- business: 737,
407
- calendar: 2391
408
- },
409
- full_resolution_time_in_minutes: {
410
- business: 737,
411
- calendar: 2391
412
- },
413
- group_stations: 7,
414
- id: 33,
415
- initially_assigned_at: "2011-05-03T10:38:52Z",
416
- latest_comment_added_at: "2011-05-09T10:38:52Z",
417
- on_hold_time_in_minutes: {
418
- business: 637,
419
- calendar: 2290
420
- },
421
- reopens: 55,
422
- replies: 322,
423
- reply_time_in_minutes: {
424
- business: 737,
425
- calendar: 2391
426
- },
427
- reply_time_in_seconds: { calendar: 143460 },
428
- requester_updated_at: "2011-05-07T10:38:52Z",
429
- requester_wait_time_in_minutes: {
430
- business: 737,
431
- calendar: 2391
432
- },
433
- solved_at: "2011-05-09T10:38:52Z",
434
- status_updated_at: "2011-05-04T10:38:52Z",
435
- ticket_id: 4343,
436
- updated_at: "2011-05-05T10:38:52Z"
437
- };
438
- //#endregion
439
- //#region src/index.ts
440
- function createZendeskClient(opts) {
441
- const rest = createZendeskRestClient(opts);
442
- return {
443
- activities: activities(rest),
444
- comments: comments(rest),
445
- fields: fields(rest),
446
- search: search(rest),
447
- status: status(rest),
448
- tickets: tickets(rest)
449
- };
450
- }
451
- //#endregion
452
- export { createToken, createZendeskClient, mockActivity, mockActivityResponse, mockAttachment, mockComment, mockCommentResponse, mockCustomField1, mockCustomField2, mockCustomFields, mockCustomStatus, mockCustomStatusResponse, mockCustomStatusesResponse, mockDefaultStatus, mockGroup, mockImage, mockMetadata, mockSearchResponseGroups, mockSearchResponseTickets, mockSearchResponseUsers, mockThumbnail, mockTicket, mockTicketField, mockTicketFieldResponse, mockTicketFieldsResponse, mockTicketMetric, mockTicketResponse, mockTicketsResponse, mockUser, mockVia };