@webex/contact-center 3.8.1 → 3.9.0-multi-llms.2
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/cc.js +196 -47
- package/dist/cc.js.map +1 -1
- package/dist/constants.js +1 -0
- package/dist/constants.js.map +1 -1
- package/dist/index.js +13 -1
- package/dist/index.js.map +1 -1
- package/dist/logger-proxy.js +24 -1
- package/dist/logger-proxy.js.map +1 -1
- package/dist/metrics/MetricsManager.js +1 -1
- package/dist/metrics/MetricsManager.js.map +1 -1
- package/dist/metrics/behavioral-events.js +88 -0
- package/dist/metrics/behavioral-events.js.map +1 -1
- package/dist/metrics/constants.js +32 -2
- package/dist/metrics/constants.js.map +1 -1
- package/dist/services/AddressBook.js +271 -0
- package/dist/services/AddressBook.js.map +1 -0
- package/dist/services/EntryPoint.js +227 -0
- package/dist/services/EntryPoint.js.map +1 -0
- package/dist/services/Queue.js +261 -0
- package/dist/services/Queue.js.map +1 -0
- package/dist/services/config/constants.js +36 -2
- package/dist/services/config/constants.js.map +1 -1
- package/dist/services/config/index.js +29 -21
- package/dist/services/config/index.js.map +1 -1
- package/dist/services/config/types.js +33 -1
- package/dist/services/config/types.js.map +1 -1
- package/dist/services/core/GlobalTypes.js.map +1 -1
- package/dist/services/core/Utils.js +162 -2
- package/dist/services/core/Utils.js.map +1 -1
- package/dist/services/core/aqm-reqs.js +0 -4
- package/dist/services/core/aqm-reqs.js.map +1 -1
- package/dist/services/core/websocket/WebSocketManager.js +0 -4
- package/dist/services/core/websocket/WebSocketManager.js.map +1 -1
- package/dist/services/task/TaskManager.js +74 -2
- package/dist/services/task/TaskManager.js.map +1 -1
- package/dist/services/task/constants.js +7 -1
- package/dist/services/task/constants.js.map +1 -1
- package/dist/services/task/contact.js +86 -0
- package/dist/services/task/contact.js.map +1 -1
- package/dist/services/task/index.js +384 -72
- package/dist/services/task/index.js.map +1 -1
- package/dist/services/task/types.js +14 -0
- package/dist/services/task/types.js.map +1 -1
- package/dist/types/cc.d.ts +115 -35
- package/dist/types/constants.d.ts +1 -0
- package/dist/types/index.d.ts +8 -3
- package/dist/types/metrics/constants.d.ts +25 -1
- package/dist/types/services/AddressBook.d.ts +74 -0
- package/dist/types/services/EntryPoint.d.ts +67 -0
- package/dist/types/services/Queue.d.ts +76 -0
- package/dist/types/services/config/constants.d.ts +35 -1
- package/dist/types/services/config/index.d.ts +6 -9
- package/dist/types/services/config/types.d.ts +79 -58
- package/dist/types/services/core/GlobalTypes.d.ts +25 -0
- package/dist/types/services/core/Utils.d.ts +40 -1
- package/dist/types/services/task/constants.d.ts +6 -0
- package/dist/types/services/task/contact.d.ts +10 -0
- package/dist/types/services/task/index.d.ts +44 -2
- package/dist/types/services/task/types.d.ts +125 -1
- package/dist/types/types.d.ts +162 -0
- package/dist/types/utils/PageCache.d.ts +173 -0
- package/dist/types.js +17 -0
- package/dist/types.js.map +1 -1
- package/dist/utils/PageCache.js +192 -0
- package/dist/utils/PageCache.js.map +1 -0
- package/dist/webex.js +1 -1
- package/package.json +11 -10
- package/src/cc.ts +221 -52
- package/src/constants.ts +1 -0
- package/src/index.ts +19 -3
- package/src/logger-proxy.ts +24 -1
- package/src/metrics/MetricsManager.ts +1 -1
- package/src/metrics/behavioral-events.ts +92 -0
- package/src/metrics/constants.ts +37 -1
- package/src/services/AddressBook.ts +291 -0
- package/src/services/EntryPoint.ts +241 -0
- package/src/services/Queue.ts +277 -0
- package/src/services/config/constants.ts +42 -2
- package/src/services/config/index.ts +30 -30
- package/src/services/config/types.ts +59 -58
- package/src/services/core/GlobalTypes.ts +27 -0
- package/src/services/core/Utils.ts +199 -1
- package/src/services/core/aqm-reqs.ts +0 -5
- package/src/services/core/websocket/WebSocketManager.ts +0 -4
- package/src/services/task/TaskManager.ts +79 -3
- package/src/services/task/constants.ts +6 -0
- package/src/services/task/contact.ts +80 -0
- package/src/services/task/index.ts +457 -57
- package/src/services/task/types.ts +135 -0
- package/src/types.ts +180 -0
- package/src/utils/PageCache.ts +252 -0
- package/test/unit/spec/cc.ts +77 -84
- package/test/unit/spec/metrics/MetricsManager.ts +0 -1
- package/test/unit/spec/metrics/behavioral-events.ts +56 -0
- package/test/unit/spec/services/AddressBook.ts +332 -0
- package/test/unit/spec/services/EntryPoint.ts +259 -0
- package/test/unit/spec/services/Queue.ts +323 -0
- package/test/unit/spec/services/config/index.ts +279 -65
- package/test/unit/spec/services/core/Utils.ts +50 -0
- package/test/unit/spec/services/core/aqm-reqs.ts +1 -3
- package/test/unit/spec/services/core/websocket/WebSocketManager.ts +0 -4
- package/test/unit/spec/services/task/TaskManager.ts +145 -1
- package/test/unit/spec/services/task/contact.ts +31 -1
- package/test/unit/spec/services/task/index.ts +410 -123
- package/umd/contact-center.min.js +2 -2
- package/umd/contact-center.min.js.map +1 -1
package/dist/types/types.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CallingClientConfig } from '@webex/calling';
|
|
2
2
|
import * as Agent from './services/agent/types';
|
|
3
3
|
import { Profile } from './services/config/types';
|
|
4
|
+
import { PaginatedResponse, BaseSearchParams } from './utils/PageCache';
|
|
4
5
|
/**
|
|
5
6
|
* HTTP methods supported by WebexRequest.
|
|
6
7
|
* @enum {string}
|
|
@@ -140,6 +141,10 @@ export interface LogContext {
|
|
|
140
141
|
method?: string;
|
|
141
142
|
interactionId?: string;
|
|
142
143
|
trackingId?: string;
|
|
144
|
+
/** Additional structured data to include in logs */
|
|
145
|
+
data?: Record<string, any>;
|
|
146
|
+
/** Error object to include in logs */
|
|
147
|
+
error?: Error | unknown;
|
|
143
148
|
}
|
|
144
149
|
/**
|
|
145
150
|
* Available logging severity levels.
|
|
@@ -434,6 +439,163 @@ export type StationReLoginResponse = Agent.ReloginSuccess | Error;
|
|
|
434
439
|
* @ignore
|
|
435
440
|
*/
|
|
436
441
|
export type SetStateResponse = Agent.StateChangeSuccess | Error;
|
|
442
|
+
/**
|
|
443
|
+
* AddressBook types
|
|
444
|
+
*/
|
|
445
|
+
export interface AddressBookEntry {
|
|
446
|
+
id: string;
|
|
447
|
+
organizationId?: string;
|
|
448
|
+
version?: number;
|
|
449
|
+
name: string;
|
|
450
|
+
number: string;
|
|
451
|
+
createdTime?: number;
|
|
452
|
+
lastUpdatedTime?: number;
|
|
453
|
+
}
|
|
454
|
+
export type AddressBookEntriesResponse = PaginatedResponse<AddressBookEntry>;
|
|
455
|
+
export interface AddressBookEntrySearchParams extends BaseSearchParams {
|
|
456
|
+
addressBookId?: string;
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* EntryPointRecord types
|
|
460
|
+
*/
|
|
461
|
+
export interface EntryPointRecord {
|
|
462
|
+
id: string;
|
|
463
|
+
name: string;
|
|
464
|
+
description?: string;
|
|
465
|
+
type: string;
|
|
466
|
+
isActive: boolean;
|
|
467
|
+
orgId: string;
|
|
468
|
+
createdAt?: string;
|
|
469
|
+
updatedAt?: string;
|
|
470
|
+
settings?: Record<string, any>;
|
|
471
|
+
}
|
|
472
|
+
export type EntryPointListResponse = PaginatedResponse<EntryPointRecord>;
|
|
473
|
+
export type EntryPointSearchParams = BaseSearchParams;
|
|
474
|
+
/**
|
|
475
|
+
* Queue types
|
|
476
|
+
*/
|
|
477
|
+
export interface QueueSkillRequirement {
|
|
478
|
+
organizationId?: string;
|
|
479
|
+
id?: string;
|
|
480
|
+
version?: number;
|
|
481
|
+
skillId: string;
|
|
482
|
+
skillName?: string;
|
|
483
|
+
skillType?: string;
|
|
484
|
+
condition: string;
|
|
485
|
+
skillValue: string;
|
|
486
|
+
createdTime?: number;
|
|
487
|
+
lastUpdatedTime?: number;
|
|
488
|
+
}
|
|
489
|
+
export interface QueueAgent {
|
|
490
|
+
id: string;
|
|
491
|
+
ciUserId?: string;
|
|
492
|
+
}
|
|
493
|
+
export interface AgentGroup {
|
|
494
|
+
teamId: string;
|
|
495
|
+
}
|
|
496
|
+
export interface CallDistributionGroup {
|
|
497
|
+
agentGroups: AgentGroup[];
|
|
498
|
+
order: number;
|
|
499
|
+
duration?: number;
|
|
500
|
+
}
|
|
501
|
+
export interface AssistantSkillMapping {
|
|
502
|
+
assistantSkillId?: string;
|
|
503
|
+
assistantSkillUpdatedTime?: number;
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* Configuration for a contact service queue
|
|
507
|
+
* @public
|
|
508
|
+
*/
|
|
509
|
+
export interface ContactServiceQueue {
|
|
510
|
+
/** Organization ID */
|
|
511
|
+
organizationId?: string;
|
|
512
|
+
/** Unique identifier for the queue */
|
|
513
|
+
id?: string;
|
|
514
|
+
/** Version of the queue */
|
|
515
|
+
version?: number;
|
|
516
|
+
/** Name of the Contact Service Queue */
|
|
517
|
+
name: string;
|
|
518
|
+
/** Description of the queue */
|
|
519
|
+
description?: string;
|
|
520
|
+
/** Queue type (INBOUND, OUTBOUND) */
|
|
521
|
+
queueType: 'INBOUND' | 'OUTBOUND';
|
|
522
|
+
/** Whether to check agent availability */
|
|
523
|
+
checkAgentAvailability: boolean;
|
|
524
|
+
/** Channel type (TELEPHONY, EMAIL, SOCIAL_CHANNEL, CHAT, etc.) */
|
|
525
|
+
channelType: 'TELEPHONY' | 'EMAIL' | 'FAX' | 'CHAT' | 'VIDEO' | 'OTHERS' | 'SOCIAL_CHANNEL';
|
|
526
|
+
/** Social channel type for SOCIAL_CHANNEL channelType */
|
|
527
|
+
socialChannelType?: 'MESSAGEBIRD' | 'MESSENGER' | 'WHATSAPP' | 'APPLE_BUSINESS_CHAT' | 'GOOGLE_BUSINESS_MESSAGES';
|
|
528
|
+
/** Service level threshold in seconds */
|
|
529
|
+
serviceLevelThreshold: number;
|
|
530
|
+
/** Maximum number of simultaneous contacts */
|
|
531
|
+
maxActiveContacts: number;
|
|
532
|
+
/** Maximum time in queue in seconds */
|
|
533
|
+
maxTimeInQueue: number;
|
|
534
|
+
/** Default music in queue media file ID */
|
|
535
|
+
defaultMusicInQueueMediaFileId: string;
|
|
536
|
+
/** Timezone for routing strategies */
|
|
537
|
+
timezone?: string;
|
|
538
|
+
/** Whether the queue is active */
|
|
539
|
+
active: boolean;
|
|
540
|
+
/** Whether outdial campaign is enabled */
|
|
541
|
+
outdialCampaignEnabled?: boolean;
|
|
542
|
+
/** Whether monitoring is permitted */
|
|
543
|
+
monitoringPermitted: boolean;
|
|
544
|
+
/** Whether parking is permitted */
|
|
545
|
+
parkingPermitted: boolean;
|
|
546
|
+
/** Whether recording is permitted */
|
|
547
|
+
recordingPermitted: boolean;
|
|
548
|
+
/** Whether recording all calls is permitted */
|
|
549
|
+
recordingAllCallsPermitted: boolean;
|
|
550
|
+
/** Whether pausing recording is permitted */
|
|
551
|
+
pauseRecordingPermitted: boolean;
|
|
552
|
+
/** Recording pause duration in seconds */
|
|
553
|
+
recordingPauseDuration?: number;
|
|
554
|
+
/** Control flow script URL */
|
|
555
|
+
controlFlowScriptUrl: string;
|
|
556
|
+
/** IVR requeue URL */
|
|
557
|
+
ivrRequeueUrl: string;
|
|
558
|
+
/** Overflow number for telephony */
|
|
559
|
+
overflowNumber?: string;
|
|
560
|
+
/** Vendor ID */
|
|
561
|
+
vendorId?: string;
|
|
562
|
+
/** Routing type */
|
|
563
|
+
routingType: 'LONGEST_AVAILABLE_AGENT' | 'SKILLS_BASED' | 'CIRCULAR' | 'LINEAR';
|
|
564
|
+
/** Skills-based routing type */
|
|
565
|
+
skillBasedRoutingType?: 'LONGEST_AVAILABLE_AGENT' | 'BEST_AVAILABLE_AGENT';
|
|
566
|
+
/** Queue routing type */
|
|
567
|
+
queueRoutingType: 'TEAM_BASED' | 'SKILL_BASED' | 'AGENT_BASED';
|
|
568
|
+
/** Queue skill requirements */
|
|
569
|
+
queueSkillRequirements?: QueueSkillRequirement[];
|
|
570
|
+
/** List of agents for agent-based queue */
|
|
571
|
+
agents?: QueueAgent[];
|
|
572
|
+
/** Call distribution groups */
|
|
573
|
+
callDistributionGroups: CallDistributionGroup[];
|
|
574
|
+
/** XSP version */
|
|
575
|
+
xspVersion?: string;
|
|
576
|
+
/** Subscription ID */
|
|
577
|
+
subscriptionId?: string;
|
|
578
|
+
/** Assistant skill mapping */
|
|
579
|
+
assistantSkill?: AssistantSkillMapping;
|
|
580
|
+
/** Whether this is a system default queue */
|
|
581
|
+
systemDefault?: boolean;
|
|
582
|
+
/** User who last updated agents list */
|
|
583
|
+
agentsLastUpdatedByUserName?: string;
|
|
584
|
+
/** Email of user who last updated agents list */
|
|
585
|
+
agentsLastUpdatedByUserEmailPrefix?: string;
|
|
586
|
+
/** When agents list was last updated */
|
|
587
|
+
agentsLastUpdatedTime?: number;
|
|
588
|
+
/** Creation timestamp in epoch millis */
|
|
589
|
+
createdTime?: number;
|
|
590
|
+
/** Last updated timestamp in epoch millis */
|
|
591
|
+
lastUpdatedTime?: number;
|
|
592
|
+
}
|
|
593
|
+
export type ContactServiceQueuesResponse = PaginatedResponse<ContactServiceQueue>;
|
|
594
|
+
export interface ContactServiceQueueSearchParams extends BaseSearchParams {
|
|
595
|
+
desktopProfileFilter?: boolean;
|
|
596
|
+
provisioningView?: boolean;
|
|
597
|
+
singleObjectResponse?: boolean;
|
|
598
|
+
}
|
|
437
599
|
/**
|
|
438
600
|
* Response type for buddy agents query operations.
|
|
439
601
|
* Either a success response with list of buddy agents or an error.
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Common pagination metadata interface used across all APIs.
|
|
3
|
+
* @public
|
|
4
|
+
* @template T - Additional metadata properties specific to the API
|
|
5
|
+
*/
|
|
6
|
+
export interface PaginationMeta {
|
|
7
|
+
/** Organization ID */
|
|
8
|
+
orgid?: string;
|
|
9
|
+
/** Current page number */
|
|
10
|
+
page?: number;
|
|
11
|
+
/** Page size for current data set */
|
|
12
|
+
pageSize?: number;
|
|
13
|
+
/** Number of pages */
|
|
14
|
+
totalPages?: number;
|
|
15
|
+
/** Total number of items */
|
|
16
|
+
totalRecords?: number;
|
|
17
|
+
/** Total number of items (alias for compatibility) */
|
|
18
|
+
totalItems?: number;
|
|
19
|
+
/** Current page number (alias for compatibility) */
|
|
20
|
+
currentPage?: number;
|
|
21
|
+
/** Map of pagination links */
|
|
22
|
+
links?: Record<string, string>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Common paginated response interface used across all APIs.
|
|
26
|
+
* @public
|
|
27
|
+
* @template T - The type of data items in the response
|
|
28
|
+
*/
|
|
29
|
+
export interface PaginatedResponse<T> {
|
|
30
|
+
/** Array of data items */
|
|
31
|
+
data: T[];
|
|
32
|
+
/** Pagination metadata */
|
|
33
|
+
meta: PaginationMeta;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Common search and pagination parameters interface.
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
export interface BaseSearchParams {
|
|
40
|
+
/** Search keyword */
|
|
41
|
+
search?: string;
|
|
42
|
+
/** Filter criteria using RSQL syntax */
|
|
43
|
+
filter?: string;
|
|
44
|
+
/** Attributes to be returned */
|
|
45
|
+
attributes?: string;
|
|
46
|
+
/** Page number (starts from 0) */
|
|
47
|
+
page?: number;
|
|
48
|
+
/** Number of items per page */
|
|
49
|
+
pageSize?: number;
|
|
50
|
+
/** Sort field */
|
|
51
|
+
sortBy?: string;
|
|
52
|
+
/** Sort direction */
|
|
53
|
+
sortOrder?: 'asc' | 'desc';
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Default pagination constants used across all APIs.
|
|
57
|
+
* @public
|
|
58
|
+
*/
|
|
59
|
+
export declare const PAGINATION_DEFAULTS: {
|
|
60
|
+
/** Default page number */
|
|
61
|
+
readonly PAGE: 0;
|
|
62
|
+
/** Default page size */
|
|
63
|
+
readonly PAGE_SIZE: 100;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Interface for cached page entry with metadata
|
|
67
|
+
* @public
|
|
68
|
+
*/
|
|
69
|
+
export interface PageCacheEntry<T> {
|
|
70
|
+
/** Cached data items for this page */
|
|
71
|
+
data: T[];
|
|
72
|
+
/** Timestamp when this page was cached */
|
|
73
|
+
timestamp: number;
|
|
74
|
+
/** Total metadata if available */
|
|
75
|
+
totalMeta?: {
|
|
76
|
+
totalPages?: number;
|
|
77
|
+
totalRecords?: number;
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Interface for cache validation parameters
|
|
82
|
+
* @public
|
|
83
|
+
*/
|
|
84
|
+
export interface CacheValidationParams {
|
|
85
|
+
/** Search query parameter */
|
|
86
|
+
search?: string;
|
|
87
|
+
/** Filter parameter */
|
|
88
|
+
filter?: string;
|
|
89
|
+
/** Attributes parameter */
|
|
90
|
+
attributes?: string;
|
|
91
|
+
/** Sort by parameter */
|
|
92
|
+
sortBy?: string;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Page cache utility class for managing paginated API response caching.
|
|
96
|
+
* Provides consistent caching behavior across all Contact Center APIs.
|
|
97
|
+
*
|
|
98
|
+
* @class PageCache
|
|
99
|
+
* @public
|
|
100
|
+
* @template T - The type of data items being cached
|
|
101
|
+
* @example
|
|
102
|
+
* ```typescript
|
|
103
|
+
* // Create a cache instance for a specific data type
|
|
104
|
+
* const cache = new PageCache<AddressBookEntry>('AddressBook');
|
|
105
|
+
*
|
|
106
|
+
* // Check if we can use cache (no search/filter parameters)
|
|
107
|
+
* if (cache.canUseCache({ search, filter })) {
|
|
108
|
+
* const cacheKey = cache.buildCacheKey(orgId, page, pageSize);
|
|
109
|
+
* const cachedPage = cache.getCachedPage(cacheKey);
|
|
110
|
+
*
|
|
111
|
+
* if (cachedPage) {
|
|
112
|
+
* return cachedPage.data;
|
|
113
|
+
* }
|
|
114
|
+
* }
|
|
115
|
+
*
|
|
116
|
+
* // Cache API response
|
|
117
|
+
* cache.cachePage(cacheKey, responseData, responseMeta);
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
export declare class PageCache<T> {
|
|
121
|
+
private cache;
|
|
122
|
+
private apiName;
|
|
123
|
+
/**
|
|
124
|
+
* Creates an instance of PageCache
|
|
125
|
+
* @param {string} apiName - Name of the API using this cache (for logging)
|
|
126
|
+
* @public
|
|
127
|
+
*/
|
|
128
|
+
constructor(apiName: string);
|
|
129
|
+
/**
|
|
130
|
+
* Checks if cache can be used for the given parameters.
|
|
131
|
+
* Cache is only used for simple pagination without search/filter/attributes/sort.
|
|
132
|
+
* @param {CacheValidationParams} params - Parameters to validate
|
|
133
|
+
* @returns {boolean} True if cache can be used
|
|
134
|
+
* @public
|
|
135
|
+
*/
|
|
136
|
+
canUseCache(params: CacheValidationParams): boolean;
|
|
137
|
+
/**
|
|
138
|
+
* Builds a cache key for the given parameters
|
|
139
|
+
* @param {string} orgId - Organization ID
|
|
140
|
+
* @param {number} page - Page number
|
|
141
|
+
* @param {number} pageSize - Page size
|
|
142
|
+
* @returns {string} Cache key
|
|
143
|
+
* @public
|
|
144
|
+
*/
|
|
145
|
+
buildCacheKey(orgId: string, page: number, pageSize: number): string;
|
|
146
|
+
/**
|
|
147
|
+
* Gets a cached page if it exists and is valid
|
|
148
|
+
* @param {string} cacheKey - Cache key to look up
|
|
149
|
+
* @returns {PageCacheEntry<T> | null} Cached page entry or null if not found/expired
|
|
150
|
+
* @public
|
|
151
|
+
*/
|
|
152
|
+
getCachedPage(cacheKey: string): PageCacheEntry<T> | null;
|
|
153
|
+
/**
|
|
154
|
+
* Caches a page of data with metadata
|
|
155
|
+
* @param {string} cacheKey - Cache key
|
|
156
|
+
* @param {T[]} data - Data items to cache
|
|
157
|
+
* @param {any} meta - Metadata from API response
|
|
158
|
+
* @public
|
|
159
|
+
*/
|
|
160
|
+
cachePage(cacheKey: string, data: T[], meta?: any): void;
|
|
161
|
+
/**
|
|
162
|
+
* Clears all cached entries
|
|
163
|
+
* @public
|
|
164
|
+
*/
|
|
165
|
+
clearCache(): void;
|
|
166
|
+
/**
|
|
167
|
+
* Gets the current number of cached entries
|
|
168
|
+
* @returns {number} Number of cached entries
|
|
169
|
+
* @public
|
|
170
|
+
*/
|
|
171
|
+
getCacheSize(): number;
|
|
172
|
+
}
|
|
173
|
+
export default PageCache;
|
package/dist/types.js
CHANGED
|
@@ -274,6 +274,23 @@ const LoginOption = exports.LoginOption = {
|
|
|
274
274
|
* @ignore
|
|
275
275
|
*/
|
|
276
276
|
|
|
277
|
+
/**
|
|
278
|
+
* AddressBook types
|
|
279
|
+
*/
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* EntryPointRecord types
|
|
283
|
+
*/
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Queue types
|
|
287
|
+
*/
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Configuration for a contact service queue
|
|
291
|
+
* @public
|
|
292
|
+
*/
|
|
293
|
+
|
|
277
294
|
/**
|
|
278
295
|
* Response type for buddy agents query operations.
|
|
279
296
|
* Either a success response with list of buddy agents or an error.
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["HTTP_METHODS","exports","GET","POST","PATCH","PUT","DELETE","LOGGING_LEVEL","LoginOption","AGENT_DN","EXTENSION","BROWSER"],"sources":["types.ts"],"sourcesContent":["import {CallingClientConfig} from '@webex/calling';\nimport {\n SubmitBehavioralEvent,\n SubmitOperationalEvent,\n SubmitBusinessEvent,\n} from '@webex/internal-plugin-metrics/src/metrics.types';\nimport * as Agent from './services/agent/types';\nimport * as Contact from './services/task/types';\nimport {Profile} from './services/config/types';\n\n/**\n * Generic type for converting a const enum object into a union type of its values.\n * @template T The enum object type\n * @internal\n * @ignore\n */\ntype Enum<T extends Record<string, unknown>> = T[keyof T];\n\n/**\n * HTTP methods supported by WebexRequest.\n * @enum {string}\n * @public\n * @example\n * const method: HTTP_METHODS = HTTP_METHODS.GET;\n * @ignore\n */\nexport const HTTP_METHODS = {\n /** HTTP GET method for retrieving data */\n GET: 'GET',\n /** HTTP POST method for creating resources */\n POST: 'POST',\n /** HTTP PATCH method for partial updates */\n PATCH: 'PATCH',\n /** HTTP PUT method for complete updates */\n PUT: 'PUT',\n /** HTTP DELETE method for removing resources */\n DELETE: 'DELETE',\n} as const;\n\n/**\n * Union type of HTTP methods.\n * @public\n * @example\n * function makeRequest(method: HTTP_METHODS) { ... }\n * @ignore\n */\nexport type HTTP_METHODS = Enum<typeof HTTP_METHODS>;\n\n/**\n * Payload for making requests to Webex APIs.\n * @public\n * @example\n * const payload: WebexRequestPayload = {\n * service: 'identity',\n * resource: '/users',\n * method: HTTP_METHODS.GET\n * };\n * @ignore\n */\nexport type WebexRequestPayload = {\n /** Service name to target */\n service?: string;\n /** Resource path within the service */\n resource?: string;\n /** HTTP method to use */\n method?: HTTP_METHODS;\n /** Full URI if not using service/resource pattern */\n uri?: string;\n /** Whether to add authorization header */\n addAuthHeader?: boolean;\n /** Custom headers to include in request */\n headers?: {\n [key: string]: string | null;\n };\n /** Request body data */\n body?: object;\n /** Expected response status code */\n statusCode?: number;\n /** Whether to parse response as JSON */\n json?: boolean;\n};\n\n/**\n * Event listener function type.\n * @internal\n * @ignore\n */\ntype Listener = (e: string, data?: unknown) => void;\n\n/**\n * Event listener removal function type.\n * @internal\n * @ignore\n */\ntype ListenerOff = (e: string) => void;\n\n/**\n * Service host configuration.\n * @internal\n * @ignore\n */\ntype ServiceHost = {\n /** Host URL/domain for the service */\n host: string;\n /** Time-to-live in seconds */\n ttl: number;\n /** Priority level for load balancing (lower is higher priority) */\n priority: number;\n /** Unique identifier for this host */\n id: string;\n /** Whether this is the home cluster for the user */\n homeCluster?: boolean;\n};\n\n/**\n * Configuration options for the Contact Center Plugin.\n * @interface CCPluginConfig\n * @public\n * @example\n * const config: CCPluginConfig = {\n * allowMultiLogin: true,\n * allowAutomatedRelogin: false,\n * clientType: 'browser',\n * isKeepAliveEnabled: true,\n * force: false,\n * metrics: { clientName: 'myClient', clientType: 'browser' },\n * logging: { enable: true, verboseEvents: false },\n * callingClientConfig: { ... }\n * };\n */\nexport interface CCPluginConfig {\n /** Whether to allow multiple logins from different devices */\n allowMultiLogin: boolean;\n /** Whether to automatically attempt relogin on connection loss */\n allowAutomatedRelogin: boolean;\n /** The type of client making the connection */\n clientType: string;\n /** Whether to enable keep-alive messages */\n isKeepAliveEnabled: boolean;\n /** Whether to force registration */\n force: boolean;\n /** Metrics configuration */\n metrics: {\n /** Name of the client for metrics */\n clientName: string;\n /** Type of client for metrics */\n clientType: string;\n };\n /** Logging configuration */\n logging: {\n /** Whether to enable logging */\n enable: boolean;\n /** Whether to log verbose events */\n verboseEvents: boolean;\n };\n /** Configuration for the calling client */\n callingClientConfig: CallingClientConfig;\n}\n\n/**\n * Logger interface for standardized logging throughout the plugin.\n * @public\n * @example\n * logger.log('This is a log message');\n * logger.error('This is an error message');\n * @ignore\n */\nexport type Logger = {\n /** Log general messages */\n log: (payload: string) => void;\n /** Log error messages */\n error: (payload: string) => void;\n /** Log warning messages */\n warn: (payload: string) => void;\n /** Log informational messages */\n info: (payload: string) => void;\n /** Log detailed trace messages */\n trace: (payload: string) => void;\n /** Log debug messages */\n debug: (payload: string) => void;\n};\n\n/**\n * Contextual information for log entries.\n * @public\n * @ignore\n */\nexport interface LogContext {\n /** Module name where the log originated */\n module?: string;\n /** Method name where the log originated */\n method?: string;\n interactionId?: string;\n trackingId?: string;\n}\n\n/**\n * Available logging severity levels.\n * @enum {string}\n * @public\n * @example\n * const level: LOGGING_LEVEL = LOGGING_LEVEL.error;\n * @ignore\n */\nexport enum LOGGING_LEVEL {\n /** Critical failures that require immediate attention */\n error = 'ERROR',\n /** Important issues that don't prevent the system from working */\n warn = 'WARN',\n /** General informational logs */\n log = 'LOG',\n /** Detailed information about system operation */\n info = 'INFO',\n /** Highly detailed diagnostic information */\n trace = 'TRACE',\n}\n\n/**\n * Metadata for log uploads.\n * @public\n * @example\n * const meta: LogsMetaData = { feedbackId: 'fb123', correlationId: 'corr456' };\n * @ignore\n */\nexport type LogsMetaData = {\n /** Optional feedback ID to associate with logs */\n feedbackId?: string;\n /** Optional correlation ID to track related operations */\n correlationId?: string;\n};\n\n/**\n * Response from uploading logs to the server.\n * @public\n * @example\n * const response: UploadLogsResponse = { trackingid: 'track123', url: 'https://...', userId: 'user1' };\n */\nexport type UploadLogsResponse = {\n /** Tracking ID for the upload request */\n trackingid?: string;\n /** URL where the logs can be accessed */\n url?: string;\n /** ID of the user who uploaded logs */\n userId?: string;\n /** Feedback ID associated with the logs */\n feedbackId?: string;\n /** Correlation ID for tracking related operations */\n correlationId?: string;\n};\n\n/**\n * Internal Webex SDK interfaces needed for plugin integration.\n * @internal\n * @ignore\n */\ninterface IWebexInternal {\n /** Mercury service for real-time messaging */\n mercury: {\n /** Register an event listener */\n on: Listener;\n /** Remove an event listener */\n off: ListenerOff;\n /** Establish a connection to the Mercury service */\n connect: () => Promise<void>;\n /** Disconnect from the Mercury service */\n disconnect: () => Promise<void>;\n /** Whether Mercury is currently connected */\n connected: boolean;\n /** Whether Mercury is in the process of connecting */\n connecting: boolean;\n };\n /** Device information */\n device: {\n /** Current WDM URL */\n url: string;\n /** Current user's ID */\n userId: string;\n /** Current organization ID */\n orgId: string;\n /** Device version */\n version: string;\n /** Calling behavior configuration */\n callingBehavior: string;\n };\n /** Presence service */\n presence: unknown;\n /** Services discovery and management */\n services: {\n /** Get a service URL by name */\n get: (service: string) => string;\n /** Wait for service catalog to be loaded */\n waitForCatalog: (service: string) => Promise<void>;\n /** Host catalog for service discovery */\n _hostCatalog: Record<string, ServiceHost[]>;\n /** Service URLs cache */\n _serviceUrls: {\n /** Mobius calling service */\n mobius: string;\n /** Identity service */\n identity: string;\n /** Janus media server */\n janus: string;\n /** WDM (WebEx Device Management) service */\n wdm: string;\n /** BroadWorks IDP proxy service */\n broadworksIdpProxy: string;\n /** Hydra API service */\n hydra: string;\n /** Mercury API service */\n mercuryApi: string;\n /** UC Management gateway service */\n 'ucmgmt-gateway': string;\n /** Contacts service */\n contactsService: string;\n };\n };\n /** Metrics collection services */\n newMetrics: {\n /** Submit behavioral events (user actions) */\n submitBehavioralEvent: SubmitBehavioralEvent;\n /** Submit operational events (system operations) */\n submitOperationalEvent: SubmitOperationalEvent;\n /** Submit business events (business outcomes) */\n submitBusinessEvent: SubmitBusinessEvent;\n };\n /** Support functionality */\n support: {\n /** Submit logs to server */\n submitLogs: (\n metaData: LogsMetaData,\n logs: string,\n options: {\n /** Whether to submit full logs or just differences */\n type: 'diff' | 'full';\n }\n ) => Promise<UploadLogsResponse>;\n };\n}\n\n/**\n * Interface representing the WebexSDK core functionality.\n * @interface WebexSDK\n * @public\n * @example\n * const sdk: WebexSDK = ...;\n * sdk.request({ service: 'identity', resource: '/users', method: HTTP_METHODS.GET });\n * @ignore\n */\nexport interface WebexSDK {\n /** Version of the WebexSDK */\n version: string;\n /** Whether the SDK can authorize requests */\n canAuthorize: boolean;\n /** Credentials management */\n credentials: {\n /** Get the user token for authentication */\n getUserToken: () => Promise<string>;\n /** Get the organization ID */\n getOrgId: () => string;\n };\n /** Whether the SDK is ready for use */\n ready: boolean;\n /** Make a request to the Webex APIs */\n request: <T>(payload: WebexRequestPayload) => Promise<T>;\n /** Register a one-time event handler */\n once: (event: string, callBack: () => void) => void;\n /** Internal plugins and services */\n internal: IWebexInternal;\n /** Logger instance */\n logger: Logger;\n}\n\n/**\n * An interface for the `ContactCenter` class.\n * The `ContactCenter` package is designed to provide a set of APIs to perform various operations for the Agent flow within Webex Contact Center.\n * @public\n * @example\n * const cc: IContactCenter = ...;\n * cc.register().then(profile => { ... });\n * @ignore\n */\nexport interface IContactCenter {\n /**\n * Initialize the CC SDK by setting up the contact center mercury connection.\n * This establishes WebSocket connectivity for real-time communication.\n *\n * @returns A Promise that resolves to the agent's profile upon successful registration\n * @public\n * @example\n * cc.register().then(profile => { ... });\n */\n register(): Promise<Profile>;\n}\n\n/**\n * Generic HTTP response structure.\n * @public\n * @example\n * const response: IHttpResponse = { body: {}, statusCode: 200, method: 'GET', headers: {}, url: '...' };\n * @ignore\n */\nexport interface IHttpResponse {\n /** Response body content */\n body: any;\n /** HTTP status code */\n statusCode: number;\n /** HTTP method used for the request */\n method: string;\n /** Response headers */\n headers: Headers;\n /** Request URL */\n url: string;\n}\n\n/**\n * Supported login options for agent authentication.\n * @public\n * @example\n * const option: LoginOption = LoginOption.AGENT_DN;\n * @ignore\n */\nexport const LoginOption = {\n /** Login using agent's direct number */\n AGENT_DN: 'AGENT_DN',\n /** Login using an extension number */\n EXTENSION: 'EXTENSION',\n /** Login using browser WebRTC capabilities */\n BROWSER: 'BROWSER',\n} as const;\n\n/**\n * Union type of login options.\n * @public\n * @example\n * function login(option: LoginOption) { ... }\n * @ignore\n */\nexport type LoginOption = Enum<typeof LoginOption>;\n\n/**\n * Request payload for subscribing to the contact center websocket.\n * @public\n * @example\n * const req: SubscribeRequest = { force: true, isKeepAliveEnabled: true, clientType: 'browser', allowMultiLogin: false };\n * @ignore\n */\nexport type SubscribeRequest = {\n /** Whether to force connection even if another exists */\n force: boolean;\n /** Whether to send keepalive messages */\n isKeepAliveEnabled: boolean;\n /** Type of client connecting */\n clientType: string;\n /** Whether to allow login from multiple devices */\n allowMultiLogin: boolean;\n};\n\n/**\n * Represents the response from getListOfTeams method.\n * Teams are groups of agents that can be managed together.\n * @public\n * @example\n * const team: Team = { id: 'team1', name: 'Support', desktopLayoutId: 'layout1' };\n * @ignore\n */\nexport type Team = {\n /**\n * Unique identifier of the team.\n */\n id: string;\n\n /**\n * Display name of the team.\n */\n name: string;\n\n /**\n * Associated desktop layout ID for the team.\n * Controls how the agent desktop is displayed for team members.\n */\n desktopLayoutId?: string;\n};\n\n/**\n * Represents the request to perform agent login.\n * @public\n * @example\n * const login: AgentLogin = { dialNumber: '1234', teamId: 'team1', loginOption: LoginOption.AGENT_DN };\n */\nexport type AgentLogin = {\n /**\n * A dialNumber field contains the number to dial such as a route point or extension.\n * Required for AGENT_DN and EXTENSION login options.\n */\n dialNumber?: string;\n\n /**\n * The unique ID representing a team of users.\n * The agent must belong to this team.\n */\n teamId: string;\n\n /**\n * The loginOption field specifies the type of login method.\n * Controls how calls are delivered to the agent.\n */\n loginOption: LoginOption;\n};\n\n/**\n * Represents the request to update agent profile settings.\n * @public\n * @example\n * const update: AgentProfileUpdate = { loginOption: LoginOption.BROWSER, dialNumber: '5678' };\n */\nexport type AgentProfileUpdate = Pick<AgentLogin, 'loginOption' | 'dialNumber' | 'teamId'>;\n\n/**\n * Union type for all possible request body types.\n * @internal\n * @ignore\n */\nexport type RequestBody =\n | SubscribeRequest\n | Agent.Logout\n | Agent.UserStationLogin\n | Agent.StateChange\n | Agent.BuddyAgents\n | Contact.HoldResumePayload\n | Contact.ResumeRecordingPayload\n | Contact.ConsultPayload\n | Contact.ConsultEndAPIPayload // API Payload accepts only QueueId wheres SDK API allows more params\n | Contact.TransferPayLoad\n | Contact.ConsultTransferPayLoad\n | Contact.cancelCtq\n | Contact.WrapupPayLoad\n | Contact.DialerPayload;\n\n/**\n * Represents the options to fetch buddy agents for the logged in agent.\n * Buddy agents are other agents who can be consulted or transfered to.\n * @public\n * @example\n * const opts: BuddyAgents = { mediaType: 'telephony', state: 'Available' };\n * @ignore\n */\nexport type BuddyAgents = {\n /**\n * The media type channel to filter buddy agents.\n * Determines which channel capability the returned agents must have.\n */\n mediaType: 'telephony' | 'chat' | 'social' | 'email';\n\n /**\n * Optional filter for agent state.\n * If specified, returns only agents in that state.\n * If omitted, returns both available and idle agents.\n */\n state?: 'Available' | 'Idle';\n};\n\n/**\n * Generic error structure for Contact Center SDK errors.\n * Contains detailed information about the error context.\n * @public\n * @example\n * const err: GenericError = new Error('Failed');\n * err.details = { type: 'ERR', orgId: 'org1', trackingId: 'track1', data: {} };\n * @ignore\n */\nexport interface GenericError extends Error {\n /** Structured details about the error */\n details: {\n /** Error type identifier */\n type: string;\n /** Organization ID where the error occurred */\n orgId: string;\n /** Unique tracking ID for the error */\n trackingId: string;\n /** Additional error context data */\n data: Record<string, any>;\n };\n}\n\n/**\n * Response type for station login operations.\n * Either a success response with agent details or an error.\n * @public\n * @example\n * function handleLogin(resp: StationLoginResponse) { ... }\n */\nexport type StationLoginResponse = Agent.StationLoginSuccessResponse | Error;\n\n/**\n * Response type for station logout operations.\n * Either a success response with logout details or an error.\n * @public\n * @example\n * function handleLogout(resp: StationLogoutResponse) { ... }\n */\nexport type StationLogoutResponse = Agent.LogoutSuccess | Error;\n\n/**\n * Response type for station relogin operations.\n * Either a success response with relogin details or an error.\n * @public\n * @example\n * function handleReLogin(resp: StationReLoginResponse) { ... }\n * @ignore\n */\nexport type StationReLoginResponse = Agent.ReloginSuccess | Error;\n\n/**\n * Response type for agent state change operations.\n * Either a success response with state change details or an error.\n * @public\n * @example\n * function handleStateChange(resp: SetStateResponse) { ... }\n * @ignore\n */\nexport type SetStateResponse = Agent.StateChangeSuccess | Error;\n\n/**\n * Response type for buddy agents query operations.\n * Either a success response with list of buddy agents or an error.\n * @public\n * @example\n * function handleBuddyAgents(resp: BuddyAgentsResponse) { ... }\n */\nexport type BuddyAgentsResponse = Agent.BuddyAgentsSuccess | Error;\n\n/**\n * Response type for device type update operations.\n * Either a success response with update confirmation or an error.\n * @public\n * @example\n * function handleUpdateDeviceType(resp: UpdateDeviceTypeResponse) { ... }\n */\nexport type UpdateDeviceTypeResponse = Agent.DeviceTypeUpdateSuccess | Error;\n"],"mappings":";;;;;;AAUA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,YAAY,GAAAC,OAAA,CAAAD,YAAA,GAAG;EAC1B;EACAE,GAAG,EAAE,KAAK;EACV;EACAC,IAAI,EAAE,MAAM;EACZ;EACAC,KAAK,EAAE,OAAO;EACd;EACAC,GAAG,EAAE,KAAK;EACV;EACAC,MAAM,EAAE;AACV,CAAU;;AAEV;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAwBA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA8BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAgBA;AACA;AACA;AACA;AACA;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAPA,IAQYC,aAAa,GAAAN,OAAA,CAAAM,aAAA,0BAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAA,OAAbA,aAAa;AAAA;AAazB;AACA;AACA;AACA;AACA;AACA;AACA;AAQA;AACA;AACA;AACA;AACA;AACA;AAcA;AACA;AACA;AACA;AACA;AAqFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAyBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,WAAW,GAAAP,OAAA,CAAAO,WAAA,GAAG;EACzB;EACAC,QAAQ,EAAE,UAAU;EACpB;EACAC,SAAS,EAAE,WAAW;EACtB;EACAC,OAAO,EAAE;AACX,CAAU;;AAEV;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAmBA;AACA;AACA;AACA;AACA;AACA;;AAqBA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;;AAiBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAgBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAeA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA"}
|
|
1
|
+
{"version":3,"names":["HTTP_METHODS","exports","GET","POST","PATCH","PUT","DELETE","LOGGING_LEVEL","LoginOption","AGENT_DN","EXTENSION","BROWSER"],"sources":["types.ts"],"sourcesContent":["import {CallingClientConfig} from '@webex/calling';\nimport {\n SubmitBehavioralEvent,\n SubmitOperationalEvent,\n SubmitBusinessEvent,\n} from '@webex/internal-plugin-metrics/src/metrics.types';\nimport * as Agent from './services/agent/types';\nimport * as Contact from './services/task/types';\nimport {Profile} from './services/config/types';\nimport {PaginatedResponse, BaseSearchParams} from './utils/PageCache';\n\n/**\n * Generic type for converting a const enum object into a union type of its values.\n * @template T The enum object type\n * @internal\n * @ignore\n */\ntype Enum<T extends Record<string, unknown>> = T[keyof T];\n\n/**\n * HTTP methods supported by WebexRequest.\n * @enum {string}\n * @public\n * @example\n * const method: HTTP_METHODS = HTTP_METHODS.GET;\n * @ignore\n */\nexport const HTTP_METHODS = {\n /** HTTP GET method for retrieving data */\n GET: 'GET',\n /** HTTP POST method for creating resources */\n POST: 'POST',\n /** HTTP PATCH method for partial updates */\n PATCH: 'PATCH',\n /** HTTP PUT method for complete updates */\n PUT: 'PUT',\n /** HTTP DELETE method for removing resources */\n DELETE: 'DELETE',\n} as const;\n\n/**\n * Union type of HTTP methods.\n * @public\n * @example\n * function makeRequest(method: HTTP_METHODS) { ... }\n * @ignore\n */\nexport type HTTP_METHODS = Enum<typeof HTTP_METHODS>;\n\n/**\n * Payload for making requests to Webex APIs.\n * @public\n * @example\n * const payload: WebexRequestPayload = {\n * service: 'identity',\n * resource: '/users',\n * method: HTTP_METHODS.GET\n * };\n * @ignore\n */\nexport type WebexRequestPayload = {\n /** Service name to target */\n service?: string;\n /** Resource path within the service */\n resource?: string;\n /** HTTP method to use */\n method?: HTTP_METHODS;\n /** Full URI if not using service/resource pattern */\n uri?: string;\n /** Whether to add authorization header */\n addAuthHeader?: boolean;\n /** Custom headers to include in request */\n headers?: {\n [key: string]: string | null;\n };\n /** Request body data */\n body?: object;\n /** Expected response status code */\n statusCode?: number;\n /** Whether to parse response as JSON */\n json?: boolean;\n};\n\n/**\n * Event listener function type.\n * @internal\n * @ignore\n */\ntype Listener = (e: string, data?: unknown) => void;\n\n/**\n * Event listener removal function type.\n * @internal\n * @ignore\n */\ntype ListenerOff = (e: string) => void;\n\n/**\n * Service host configuration.\n * @internal\n * @ignore\n */\ntype ServiceHost = {\n /** Host URL/domain for the service */\n host: string;\n /** Time-to-live in seconds */\n ttl: number;\n /** Priority level for load balancing (lower is higher priority) */\n priority: number;\n /** Unique identifier for this host */\n id: string;\n /** Whether this is the home cluster for the user */\n homeCluster?: boolean;\n};\n\n/**\n * Configuration options for the Contact Center Plugin.\n * @interface CCPluginConfig\n * @public\n * @example\n * const config: CCPluginConfig = {\n * allowMultiLogin: true,\n * allowAutomatedRelogin: false,\n * clientType: 'browser',\n * isKeepAliveEnabled: true,\n * force: false,\n * metrics: { clientName: 'myClient', clientType: 'browser' },\n * logging: { enable: true, verboseEvents: false },\n * callingClientConfig: { ... }\n * };\n */\nexport interface CCPluginConfig {\n /** Whether to allow multiple logins from different devices */\n allowMultiLogin: boolean;\n /** Whether to automatically attempt relogin on connection loss */\n allowAutomatedRelogin: boolean;\n /** The type of client making the connection */\n clientType: string;\n /** Whether to enable keep-alive messages */\n isKeepAliveEnabled: boolean;\n /** Whether to force registration */\n force: boolean;\n /** Metrics configuration */\n metrics: {\n /** Name of the client for metrics */\n clientName: string;\n /** Type of client for metrics */\n clientType: string;\n };\n /** Logging configuration */\n logging: {\n /** Whether to enable logging */\n enable: boolean;\n /** Whether to log verbose events */\n verboseEvents: boolean;\n };\n /** Configuration for the calling client */\n callingClientConfig: CallingClientConfig;\n}\n\n/**\n * Logger interface for standardized logging throughout the plugin.\n * @public\n * @example\n * logger.log('This is a log message');\n * logger.error('This is an error message');\n * @ignore\n */\nexport type Logger = {\n /** Log general messages */\n log: (payload: string) => void;\n /** Log error messages */\n error: (payload: string) => void;\n /** Log warning messages */\n warn: (payload: string) => void;\n /** Log informational messages */\n info: (payload: string) => void;\n /** Log detailed trace messages */\n trace: (payload: string) => void;\n /** Log debug messages */\n debug: (payload: string) => void;\n};\n\n/**\n * Contextual information for log entries.\n * @public\n * @ignore\n */\nexport interface LogContext {\n /** Module name where the log originated */\n module?: string;\n /** Method name where the log originated */\n method?: string;\n interactionId?: string;\n trackingId?: string;\n /** Additional structured data to include in logs */\n data?: Record<string, any>;\n /** Error object to include in logs */\n error?: Error | unknown;\n}\n\n/**\n * Available logging severity levels.\n * @enum {string}\n * @public\n * @example\n * const level: LOGGING_LEVEL = LOGGING_LEVEL.error;\n * @ignore\n */\nexport enum LOGGING_LEVEL {\n /** Critical failures that require immediate attention */\n error = 'ERROR',\n /** Important issues that don't prevent the system from working */\n warn = 'WARN',\n /** General informational logs */\n log = 'LOG',\n /** Detailed information about system operation */\n info = 'INFO',\n /** Highly detailed diagnostic information */\n trace = 'TRACE',\n}\n\n/**\n * Metadata for log uploads.\n * @public\n * @example\n * const meta: LogsMetaData = { feedbackId: 'fb123', correlationId: 'corr456' };\n * @ignore\n */\nexport type LogsMetaData = {\n /** Optional feedback ID to associate with logs */\n feedbackId?: string;\n /** Optional correlation ID to track related operations */\n correlationId?: string;\n};\n\n/**\n * Response from uploading logs to the server.\n * @public\n * @example\n * const response: UploadLogsResponse = { trackingid: 'track123', url: 'https://...', userId: 'user1' };\n */\nexport type UploadLogsResponse = {\n /** Tracking ID for the upload request */\n trackingid?: string;\n /** URL where the logs can be accessed */\n url?: string;\n /** ID of the user who uploaded logs */\n userId?: string;\n /** Feedback ID associated with the logs */\n feedbackId?: string;\n /** Correlation ID for tracking related operations */\n correlationId?: string;\n};\n\n/**\n * Internal Webex SDK interfaces needed for plugin integration.\n * @internal\n * @ignore\n */\ninterface IWebexInternal {\n /** Mercury service for real-time messaging */\n mercury: {\n /** Register an event listener */\n on: Listener;\n /** Remove an event listener */\n off: ListenerOff;\n /** Establish a connection to the Mercury service */\n connect: () => Promise<void>;\n /** Disconnect from the Mercury service */\n disconnect: () => Promise<void>;\n /** Whether Mercury is currently connected */\n connected: boolean;\n /** Whether Mercury is in the process of connecting */\n connecting: boolean;\n };\n /** Device information */\n device: {\n /** Current WDM URL */\n url: string;\n /** Current user's ID */\n userId: string;\n /** Current organization ID */\n orgId: string;\n /** Device version */\n version: string;\n /** Calling behavior configuration */\n callingBehavior: string;\n };\n /** Presence service */\n presence: unknown;\n /** Services discovery and management */\n services: {\n /** Get a service URL by name */\n get: (service: string) => string;\n /** Wait for service catalog to be loaded */\n waitForCatalog: (service: string) => Promise<void>;\n /** Host catalog for service discovery */\n _hostCatalog: Record<string, ServiceHost[]>;\n /** Service URLs cache */\n _serviceUrls: {\n /** Mobius calling service */\n mobius: string;\n /** Identity service */\n identity: string;\n /** Janus media server */\n janus: string;\n /** WDM (WebEx Device Management) service */\n wdm: string;\n /** BroadWorks IDP proxy service */\n broadworksIdpProxy: string;\n /** Hydra API service */\n hydra: string;\n /** Mercury API service */\n mercuryApi: string;\n /** UC Management gateway service */\n 'ucmgmt-gateway': string;\n /** Contacts service */\n contactsService: string;\n };\n };\n /** Metrics collection services */\n newMetrics: {\n /** Submit behavioral events (user actions) */\n submitBehavioralEvent: SubmitBehavioralEvent;\n /** Submit operational events (system operations) */\n submitOperationalEvent: SubmitOperationalEvent;\n /** Submit business events (business outcomes) */\n submitBusinessEvent: SubmitBusinessEvent;\n };\n /** Support functionality */\n support: {\n /** Submit logs to server */\n submitLogs: (\n metaData: LogsMetaData,\n logs: string,\n options: {\n /** Whether to submit full logs or just differences */\n type: 'diff' | 'full';\n }\n ) => Promise<UploadLogsResponse>;\n };\n}\n\n/**\n * Interface representing the WebexSDK core functionality.\n * @interface WebexSDK\n * @public\n * @example\n * const sdk: WebexSDK = ...;\n * sdk.request({ service: 'identity', resource: '/users', method: HTTP_METHODS.GET });\n * @ignore\n */\nexport interface WebexSDK {\n /** Version of the WebexSDK */\n version: string;\n /** Whether the SDK can authorize requests */\n canAuthorize: boolean;\n /** Credentials management */\n credentials: {\n /** Get the user token for authentication */\n getUserToken: () => Promise<string>;\n /** Get the organization ID */\n getOrgId: () => string;\n };\n /** Whether the SDK is ready for use */\n ready: boolean;\n /** Make a request to the Webex APIs */\n request: <T>(payload: WebexRequestPayload) => Promise<T>;\n /** Register a one-time event handler */\n once: (event: string, callBack: () => void) => void;\n /** Internal plugins and services */\n internal: IWebexInternal;\n /** Logger instance */\n logger: Logger;\n}\n\n/**\n * An interface for the `ContactCenter` class.\n * The `ContactCenter` package is designed to provide a set of APIs to perform various operations for the Agent flow within Webex Contact Center.\n * @public\n * @example\n * const cc: IContactCenter = ...;\n * cc.register().then(profile => { ... });\n * @ignore\n */\nexport interface IContactCenter {\n /**\n * Initialize the CC SDK by setting up the contact center mercury connection.\n * This establishes WebSocket connectivity for real-time communication.\n *\n * @returns A Promise that resolves to the agent's profile upon successful registration\n * @public\n * @example\n * cc.register().then(profile => { ... });\n */\n register(): Promise<Profile>;\n}\n\n/**\n * Generic HTTP response structure.\n * @public\n * @example\n * const response: IHttpResponse = { body: {}, statusCode: 200, method: 'GET', headers: {}, url: '...' };\n * @ignore\n */\nexport interface IHttpResponse {\n /** Response body content */\n body: any;\n /** HTTP status code */\n statusCode: number;\n /** HTTP method used for the request */\n method: string;\n /** Response headers */\n headers: Headers;\n /** Request URL */\n url: string;\n}\n\n/**\n * Supported login options for agent authentication.\n * @public\n * @example\n * const option: LoginOption = LoginOption.AGENT_DN;\n * @ignore\n */\nexport const LoginOption = {\n /** Login using agent's direct number */\n AGENT_DN: 'AGENT_DN',\n /** Login using an extension number */\n EXTENSION: 'EXTENSION',\n /** Login using browser WebRTC capabilities */\n BROWSER: 'BROWSER',\n} as const;\n\n/**\n * Union type of login options.\n * @public\n * @example\n * function login(option: LoginOption) { ... }\n * @ignore\n */\nexport type LoginOption = Enum<typeof LoginOption>;\n\n/**\n * Request payload for subscribing to the contact center websocket.\n * @public\n * @example\n * const req: SubscribeRequest = { force: true, isKeepAliveEnabled: true, clientType: 'browser', allowMultiLogin: false };\n * @ignore\n */\nexport type SubscribeRequest = {\n /** Whether to force connection even if another exists */\n force: boolean;\n /** Whether to send keepalive messages */\n isKeepAliveEnabled: boolean;\n /** Type of client connecting */\n clientType: string;\n /** Whether to allow login from multiple devices */\n allowMultiLogin: boolean;\n};\n\n/**\n * Represents the response from getListOfTeams method.\n * Teams are groups of agents that can be managed together.\n * @public\n * @example\n * const team: Team = { id: 'team1', name: 'Support', desktopLayoutId: 'layout1' };\n * @ignore\n */\nexport type Team = {\n /**\n * Unique identifier of the team.\n */\n id: string;\n\n /**\n * Display name of the team.\n */\n name: string;\n\n /**\n * Associated desktop layout ID for the team.\n * Controls how the agent desktop is displayed for team members.\n */\n desktopLayoutId?: string;\n};\n\n/**\n * Represents the request to perform agent login.\n * @public\n * @example\n * const login: AgentLogin = { dialNumber: '1234', teamId: 'team1', loginOption: LoginOption.AGENT_DN };\n */\nexport type AgentLogin = {\n /**\n * A dialNumber field contains the number to dial such as a route point or extension.\n * Required for AGENT_DN and EXTENSION login options.\n */\n dialNumber?: string;\n\n /**\n * The unique ID representing a team of users.\n * The agent must belong to this team.\n */\n teamId: string;\n\n /**\n * The loginOption field specifies the type of login method.\n * Controls how calls are delivered to the agent.\n */\n loginOption: LoginOption;\n};\n\n/**\n * Represents the request to update agent profile settings.\n * @public\n * @example\n * const update: AgentProfileUpdate = { loginOption: LoginOption.BROWSER, dialNumber: '5678' };\n */\nexport type AgentProfileUpdate = Pick<AgentLogin, 'loginOption' | 'dialNumber' | 'teamId'>;\n\n/**\n * Union type for all possible request body types.\n * @internal\n * @ignore\n */\nexport type RequestBody =\n | SubscribeRequest\n | Agent.Logout\n | Agent.UserStationLogin\n | Agent.StateChange\n | Agent.BuddyAgents\n | Contact.HoldResumePayload\n | Contact.ResumeRecordingPayload\n | Contact.ConsultPayload\n | Contact.ConsultEndAPIPayload // API Payload accepts only QueueId wheres SDK API allows more params\n | Contact.TransferPayLoad\n | Contact.ConsultTransferPayLoad\n | Contact.cancelCtq\n | Contact.WrapupPayLoad\n | Contact.DialerPayload;\n\n/**\n * Represents the options to fetch buddy agents for the logged in agent.\n * Buddy agents are other agents who can be consulted or transfered to.\n * @public\n * @example\n * const opts: BuddyAgents = { mediaType: 'telephony', state: 'Available' };\n * @ignore\n */\nexport type BuddyAgents = {\n /**\n * The media type channel to filter buddy agents.\n * Determines which channel capability the returned agents must have.\n */\n mediaType: 'telephony' | 'chat' | 'social' | 'email';\n\n /**\n * Optional filter for agent state.\n * If specified, returns only agents in that state.\n * If omitted, returns both available and idle agents.\n */\n state?: 'Available' | 'Idle';\n};\n\n/**\n * Generic error structure for Contact Center SDK errors.\n * Contains detailed information about the error context.\n * @public\n * @example\n * const err: GenericError = new Error('Failed');\n * err.details = { type: 'ERR', orgId: 'org1', trackingId: 'track1', data: {} };\n * @ignore\n */\nexport interface GenericError extends Error {\n /** Structured details about the error */\n details: {\n /** Error type identifier */\n type: string;\n /** Organization ID where the error occurred */\n orgId: string;\n /** Unique tracking ID for the error */\n trackingId: string;\n /** Additional error context data */\n data: Record<string, any>;\n };\n}\n\n/**\n * Response type for station login operations.\n * Either a success response with agent details or an error.\n * @public\n * @example\n * function handleLogin(resp: StationLoginResponse) { ... }\n */\nexport type StationLoginResponse = Agent.StationLoginSuccessResponse | Error;\n\n/**\n * Response type for station logout operations.\n * Either a success response with logout details or an error.\n * @public\n * @example\n * function handleLogout(resp: StationLogoutResponse) { ... }\n */\nexport type StationLogoutResponse = Agent.LogoutSuccess | Error;\n\n/**\n * Response type for station relogin operations.\n * Either a success response with relogin details or an error.\n * @public\n * @example\n * function handleReLogin(resp: StationReLoginResponse) { ... }\n * @ignore\n */\nexport type StationReLoginResponse = Agent.ReloginSuccess | Error;\n\n/**\n * Response type for agent state change operations.\n * Either a success response with state change details or an error.\n * @public\n * @example\n * function handleStateChange(resp: SetStateResponse) { ... }\n * @ignore\n */\nexport type SetStateResponse = Agent.StateChangeSuccess | Error;\n\n/**\n * AddressBook types\n */\nexport interface AddressBookEntry {\n id: string;\n organizationId?: string;\n version?: number;\n name: string;\n number: string;\n createdTime?: number;\n lastUpdatedTime?: number;\n}\n\nexport type AddressBookEntriesResponse = PaginatedResponse<AddressBookEntry>;\n\nexport interface AddressBookEntrySearchParams extends BaseSearchParams {\n addressBookId?: string;\n}\n\n/**\n * EntryPointRecord types\n */\nexport interface EntryPointRecord {\n id: string;\n name: string;\n description?: string;\n type: string;\n isActive: boolean;\n orgId: string;\n createdAt?: string;\n updatedAt?: string;\n settings?: Record<string, any>;\n}\n\nexport type EntryPointListResponse = PaginatedResponse<EntryPointRecord>;\nexport type EntryPointSearchParams = BaseSearchParams;\n\n/**\n * Queue types\n */\nexport interface QueueSkillRequirement {\n organizationId?: string;\n id?: string;\n version?: number;\n skillId: string;\n skillName?: string;\n skillType?: string;\n condition: string;\n skillValue: string;\n createdTime?: number;\n lastUpdatedTime?: number;\n}\n\nexport interface QueueAgent {\n id: string;\n ciUserId?: string;\n}\n\nexport interface AgentGroup {\n teamId: string;\n}\n\nexport interface CallDistributionGroup {\n agentGroups: AgentGroup[];\n order: number;\n duration?: number;\n}\n\nexport interface AssistantSkillMapping {\n assistantSkillId?: string;\n assistantSkillUpdatedTime?: number;\n}\n\n/**\n * Configuration for a contact service queue\n * @public\n */\nexport interface ContactServiceQueue {\n /** Organization ID */\n organizationId?: string;\n /** Unique identifier for the queue */\n id?: string;\n /** Version of the queue */\n version?: number;\n /** Name of the Contact Service Queue */\n name: string;\n /** Description of the queue */\n description?: string;\n /** Queue type (INBOUND, OUTBOUND) */\n queueType: 'INBOUND' | 'OUTBOUND';\n /** Whether to check agent availability */\n checkAgentAvailability: boolean;\n /** Channel type (TELEPHONY, EMAIL, SOCIAL_CHANNEL, CHAT, etc.) */\n channelType: 'TELEPHONY' | 'EMAIL' | 'FAX' | 'CHAT' | 'VIDEO' | 'OTHERS' | 'SOCIAL_CHANNEL';\n /** Social channel type for SOCIAL_CHANNEL channelType */\n socialChannelType?:\n | 'MESSAGEBIRD'\n | 'MESSENGER'\n | 'WHATSAPP'\n | 'APPLE_BUSINESS_CHAT'\n | 'GOOGLE_BUSINESS_MESSAGES';\n /** Service level threshold in seconds */\n serviceLevelThreshold: number;\n /** Maximum number of simultaneous contacts */\n maxActiveContacts: number;\n /** Maximum time in queue in seconds */\n maxTimeInQueue: number;\n /** Default music in queue media file ID */\n defaultMusicInQueueMediaFileId: string;\n /** Timezone for routing strategies */\n timezone?: string;\n /** Whether the queue is active */\n active: boolean;\n /** Whether outdial campaign is enabled */\n outdialCampaignEnabled?: boolean;\n /** Whether monitoring is permitted */\n monitoringPermitted: boolean;\n /** Whether parking is permitted */\n parkingPermitted: boolean;\n /** Whether recording is permitted */\n recordingPermitted: boolean;\n /** Whether recording all calls is permitted */\n recordingAllCallsPermitted: boolean;\n /** Whether pausing recording is permitted */\n pauseRecordingPermitted: boolean;\n /** Recording pause duration in seconds */\n recordingPauseDuration?: number;\n /** Control flow script URL */\n controlFlowScriptUrl: string;\n /** IVR requeue URL */\n ivrRequeueUrl: string;\n /** Overflow number for telephony */\n overflowNumber?: string;\n /** Vendor ID */\n vendorId?: string;\n /** Routing type */\n routingType: 'LONGEST_AVAILABLE_AGENT' | 'SKILLS_BASED' | 'CIRCULAR' | 'LINEAR';\n /** Skills-based routing type */\n skillBasedRoutingType?: 'LONGEST_AVAILABLE_AGENT' | 'BEST_AVAILABLE_AGENT';\n /** Queue routing type */\n queueRoutingType: 'TEAM_BASED' | 'SKILL_BASED' | 'AGENT_BASED';\n /** Queue skill requirements */\n queueSkillRequirements?: QueueSkillRequirement[];\n /** List of agents for agent-based queue */\n agents?: QueueAgent[];\n /** Call distribution groups */\n callDistributionGroups: CallDistributionGroup[];\n /** XSP version */\n xspVersion?: string;\n /** Subscription ID */\n subscriptionId?: string;\n /** Assistant skill mapping */\n assistantSkill?: AssistantSkillMapping;\n /** Whether this is a system default queue */\n systemDefault?: boolean;\n /** User who last updated agents list */\n agentsLastUpdatedByUserName?: string;\n /** Email of user who last updated agents list */\n agentsLastUpdatedByUserEmailPrefix?: string;\n /** When agents list was last updated */\n agentsLastUpdatedTime?: number;\n /** Creation timestamp in epoch millis */\n createdTime?: number;\n /** Last updated timestamp in epoch millis */\n lastUpdatedTime?: number;\n}\n\nexport type ContactServiceQueuesResponse = PaginatedResponse<ContactServiceQueue>;\n\nexport interface ContactServiceQueueSearchParams extends BaseSearchParams {\n desktopProfileFilter?: boolean;\n provisioningView?: boolean;\n singleObjectResponse?: boolean;\n}\n\n/**\n * Response type for buddy agents query operations.\n * Either a success response with list of buddy agents or an error.\n * @public\n * @example\n * function handleBuddyAgents(resp: BuddyAgentsResponse) { ... }\n */\nexport type BuddyAgentsResponse = Agent.BuddyAgentsSuccess | Error;\n\n/**\n * Response type for device type update operations.\n * Either a success response with update confirmation or an error.\n * @public\n * @example\n * function handleUpdateDeviceType(resp: UpdateDeviceTypeResponse) { ... }\n */\nexport type UpdateDeviceTypeResponse = Agent.DeviceTypeUpdateSuccess | Error;\n"],"mappings":";;;;;;AAWA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,YAAY,GAAAC,OAAA,CAAAD,YAAA,GAAG;EAC1B;EACAE,GAAG,EAAE,KAAK;EACV;EACAC,IAAI,EAAE,MAAM;EACZ;EACAC,KAAK,EAAE,OAAO;EACd;EACAC,GAAG,EAAE,KAAK;EACV;EACAC,MAAM,EAAE;AACV,CAAU;;AAEV;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAwBA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA8BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAgBA;AACA;AACA;AACA;AACA;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAPA,IAQYC,aAAa,GAAAN,OAAA,CAAAM,aAAA,0BAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAA,OAAbA,aAAa;AAAA;AAazB;AACA;AACA;AACA;AACA;AACA;AACA;AAQA;AACA;AACA;AACA;AACA;AACA;AAcA;AACA;AACA;AACA;AACA;AAqFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAyBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,WAAW,GAAAP,OAAA,CAAAO,WAAA,GAAG;EACzB;EACAC,QAAQ,EAAE,UAAU;EACpB;EACAC,SAAS,EAAE,WAAW;EACtB;EACAC,OAAO,EAAE;AACX,CAAU;;AAEV;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAmBA;AACA;AACA;AACA;AACA;AACA;;AAqBA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;;AAiBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAgBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAeA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;;AAiBA;AACA;AACA;;AAgBA;AACA;AACA;;AAkCA;AACA;AACA;AACA;;AAmGA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA"}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.PageCache = exports.PAGINATION_DEFAULTS = void 0;
|
|
7
|
+
var _loggerProxy = _interopRequireDefault(require("../logger-proxy"));
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
+
/**
|
|
10
|
+
* Common pagination metadata interface used across all APIs.
|
|
11
|
+
* @public
|
|
12
|
+
* @template T - Additional metadata properties specific to the API
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Common paginated response interface used across all APIs.
|
|
17
|
+
* @public
|
|
18
|
+
* @template T - The type of data items in the response
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Common search and pagination parameters interface.
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Default pagination constants used across all APIs.
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
const PAGINATION_DEFAULTS = exports.PAGINATION_DEFAULTS = {
|
|
31
|
+
/** Default page number */
|
|
32
|
+
PAGE: 0,
|
|
33
|
+
/** Default page size */
|
|
34
|
+
PAGE_SIZE: 100
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Interface for cached page entry with metadata
|
|
39
|
+
* @public
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Interface for cache validation parameters
|
|
44
|
+
* @public
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Default cache TTL in minutes
|
|
49
|
+
*/
|
|
50
|
+
const DEFAULT_CACHE_TTL_MINUTES = 5;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Page cache utility class for managing paginated API response caching.
|
|
54
|
+
* Provides consistent caching behavior across all Contact Center APIs.
|
|
55
|
+
*
|
|
56
|
+
* @class PageCache
|
|
57
|
+
* @public
|
|
58
|
+
* @template T - The type of data items being cached
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* // Create a cache instance for a specific data type
|
|
62
|
+
* const cache = new PageCache<AddressBookEntry>('AddressBook');
|
|
63
|
+
*
|
|
64
|
+
* // Check if we can use cache (no search/filter parameters)
|
|
65
|
+
* if (cache.canUseCache({ search, filter })) {
|
|
66
|
+
* const cacheKey = cache.buildCacheKey(orgId, page, pageSize);
|
|
67
|
+
* const cachedPage = cache.getCachedPage(cacheKey);
|
|
68
|
+
*
|
|
69
|
+
* if (cachedPage) {
|
|
70
|
+
* return cachedPage.data;
|
|
71
|
+
* }
|
|
72
|
+
* }
|
|
73
|
+
*
|
|
74
|
+
* // Cache API response
|
|
75
|
+
* cache.cachePage(cacheKey, responseData, responseMeta);
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
class PageCache {
|
|
79
|
+
cache = new Map();
|
|
80
|
+
/**
|
|
81
|
+
* Creates an instance of PageCache
|
|
82
|
+
* @param {string} apiName - Name of the API using this cache (for logging)
|
|
83
|
+
* @public
|
|
84
|
+
*/
|
|
85
|
+
constructor(apiName) {
|
|
86
|
+
this.apiName = apiName;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Checks if cache can be used for the given parameters.
|
|
91
|
+
* Cache is only used for simple pagination without search/filter/attributes/sort.
|
|
92
|
+
* @param {CacheValidationParams} params - Parameters to validate
|
|
93
|
+
* @returns {boolean} True if cache can be used
|
|
94
|
+
* @public
|
|
95
|
+
*/
|
|
96
|
+
canUseCache(params) {
|
|
97
|
+
const {
|
|
98
|
+
search,
|
|
99
|
+
filter,
|
|
100
|
+
attributes,
|
|
101
|
+
sortBy
|
|
102
|
+
} = params;
|
|
103
|
+
return !search && !filter && !attributes && !sortBy;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Builds a cache key for the given parameters
|
|
108
|
+
* @param {string} orgId - Organization ID
|
|
109
|
+
* @param {number} page - Page number
|
|
110
|
+
* @param {number} pageSize - Page size
|
|
111
|
+
* @returns {string} Cache key
|
|
112
|
+
* @public
|
|
113
|
+
*/
|
|
114
|
+
buildCacheKey(orgId, page, pageSize) {
|
|
115
|
+
return `${orgId}:${page}:${pageSize}`;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Gets a cached page if it exists and is valid
|
|
120
|
+
* @param {string} cacheKey - Cache key to look up
|
|
121
|
+
* @returns {PageCacheEntry<T> | null} Cached page entry or null if not found/expired
|
|
122
|
+
* @public
|
|
123
|
+
*/
|
|
124
|
+
getCachedPage(cacheKey) {
|
|
125
|
+
const cachedEntry = this.cache.get(cacheKey);
|
|
126
|
+
if (!cachedEntry) {
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Check if cache entry is expired
|
|
131
|
+
const now = Date.now();
|
|
132
|
+
const cacheAge = (now - cachedEntry.timestamp) / (1000 * 60); // in minutes
|
|
133
|
+
|
|
134
|
+
if (cacheAge >= DEFAULT_CACHE_TTL_MINUTES) {
|
|
135
|
+
_loggerProxy.default.log(`Cache entry expired for key: ${cacheKey}`, {
|
|
136
|
+
module: this.apiName,
|
|
137
|
+
method: 'getCachedPage'
|
|
138
|
+
});
|
|
139
|
+
this.cache.delete(cacheKey);
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
return cachedEntry;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Caches a page of data with metadata
|
|
147
|
+
* @param {string} cacheKey - Cache key
|
|
148
|
+
* @param {T[]} data - Data items to cache
|
|
149
|
+
* @param {any} meta - Metadata from API response
|
|
150
|
+
* @public
|
|
151
|
+
*/
|
|
152
|
+
cachePage(cacheKey, data, meta) {
|
|
153
|
+
const cacheEntry = {
|
|
154
|
+
data,
|
|
155
|
+
timestamp: Date.now(),
|
|
156
|
+
totalMeta: meta ? {
|
|
157
|
+
totalPages: meta.totalPages,
|
|
158
|
+
totalRecords: meta.totalRecords || meta.totalItems
|
|
159
|
+
} : undefined
|
|
160
|
+
};
|
|
161
|
+
this.cache.set(cacheKey, cacheEntry);
|
|
162
|
+
_loggerProxy.default.log(`Cached page with ${data.length} items for key: ${cacheKey}`, {
|
|
163
|
+
module: this.apiName,
|
|
164
|
+
method: 'cachePage'
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Clears all cached entries
|
|
170
|
+
* @public
|
|
171
|
+
*/
|
|
172
|
+
clearCache() {
|
|
173
|
+
const cacheSize = this.cache.size;
|
|
174
|
+
this.cache.clear();
|
|
175
|
+
_loggerProxy.default.log(`Cleared ${cacheSize} cache entries`, {
|
|
176
|
+
module: this.apiName,
|
|
177
|
+
method: 'clearCache'
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Gets the current number of cached entries
|
|
183
|
+
* @returns {number} Number of cached entries
|
|
184
|
+
* @public
|
|
185
|
+
*/
|
|
186
|
+
getCacheSize() {
|
|
187
|
+
return this.cache.size;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
exports.PageCache = PageCache;
|
|
191
|
+
var _default = exports.default = PageCache;
|
|
192
|
+
//# sourceMappingURL=PageCache.js.map
|