@webex/contact-center 3.11.0 → 3.12.0-auth-prejoin-fetch.1
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/.sdd/manifest.json +883 -0
- package/AGENTS.md +94 -0
- package/ai-docs/ARCHITECTURE.md +168 -0
- package/ai-docs/CONTRACTS.md +50 -0
- package/ai-docs/GETTING_STARTED.md +168 -0
- package/ai-docs/GLOSSARY.md +43 -0
- package/ai-docs/README.md +138 -0
- package/ai-docs/REVIEW_CHECKLIST.md +41 -0
- package/ai-docs/RULES.md +444 -0
- package/ai-docs/SECURITY.md +52 -0
- package/ai-docs/SERVICE_STATE.md +48 -0
- package/ai-docs/SPEC_INDEX.md +65 -0
- package/ai-docs/adr/0001-spec-source-policy.md +55 -0
- package/ai-docs/adr/README.md +8 -0
- package/ai-docs/adr/_adr-template.md +31 -0
- package/ai-docs/contact-center-spec.md +359 -0
- package/ai-docs/features/consult-transfer-list-policy/spec/feature-spec.md +362 -0
- package/ai-docs/features/generated-spec-conformance-fidelity-remediation/spec/feature-spec.md +117 -0
- package/ai-docs/features/residual-warning-coverage-completion/spec/feature-spec.md +203 -0
- package/ai-docs/features/validator-code-fidelity-drift-fix/spec/feature-spec.md +315 -0
- package/ai-docs/patterns/event-driven-patterns.md +485 -0
- package/ai-docs/patterns/testing-patterns.md +480 -0
- package/ai-docs/patterns/typescript-patterns.md +365 -0
- package/ai-docs/templates/README.md +102 -0
- package/ai-docs/templates/documentation/create-agents-md.md +240 -0
- package/ai-docs/templates/documentation/create-architecture-md.md +295 -0
- package/ai-docs/templates/existing-service/bug-fix.md +254 -0
- package/ai-docs/templates/existing-service/feature-enhancement.md +450 -0
- package/ai-docs/templates/new-method/00-master.md +80 -0
- package/ai-docs/templates/new-method/01-requirements.md +232 -0
- package/ai-docs/templates/new-method/02-implementation.md +295 -0
- package/ai-docs/templates/new-method/03-tests.md +201 -0
- package/ai-docs/templates/new-method/04-validation.md +141 -0
- package/ai-docs/templates/new-service/00-master.md +109 -0
- package/ai-docs/templates/new-service/01-pre-questions.md +159 -0
- package/ai-docs/templates/new-service/02-code-generation.md +346 -0
- package/ai-docs/templates/new-service/03-integration.md +178 -0
- package/ai-docs/templates/new-service/04-test-generation.md +205 -0
- package/ai-docs/templates/new-service/05-validation.md +145 -0
- package/dist/cc.js +818 -59
- package/dist/cc.js.map +1 -1
- package/dist/config.js +13 -0
- package/dist/config.js.map +1 -1
- package/dist/constants.js +31 -3
- package/dist/constants.js.map +1 -1
- package/dist/index.js +27 -5
- package/dist/index.js.map +1 -1
- package/dist/metrics/behavioral-events.js +127 -0
- package/dist/metrics/behavioral-events.js.map +1 -1
- package/dist/metrics/constants.js +34 -3
- package/dist/metrics/constants.js.map +1 -1
- package/dist/services/AddressBook.js +18 -15
- package/dist/services/AddressBook.js.map +1 -1
- package/dist/services/AnswerCallOnWebexService.js +174 -0
- package/dist/services/AnswerCallOnWebexService.js.map +1 -0
- package/dist/services/ApiAiAssistant.js +318 -0
- package/dist/services/ApiAiAssistant.js.map +1 -0
- package/dist/services/EntryPoint.js +46 -68
- package/dist/services/EntryPoint.js.map +1 -1
- package/dist/services/Queue.js +27 -22
- package/dist/services/Queue.js.map +1 -1
- package/dist/services/UserPreference.js +427 -0
- package/dist/services/UserPreference.js.map +1 -0
- package/dist/services/WebexCrossClientService.js +171 -0
- package/dist/services/WebexCrossClientService.js.map +1 -0
- package/dist/services/WxAppTelephonyMercurySync.js +93 -0
- package/dist/services/WxAppTelephonyMercurySync.js.map +1 -0
- package/dist/services/agent/types.js.map +1 -1
- package/dist/services/config/Util.js +11 -4
- package/dist/services/config/Util.js.map +1 -1
- package/dist/services/config/constants.js +45 -8
- package/dist/services/config/constants.js.map +1 -1
- package/dist/services/config/index.js +41 -2
- package/dist/services/config/index.js.map +1 -1
- package/dist/services/config/types.js +70 -8
- package/dist/services/config/types.js.map +1 -1
- package/dist/services/constants.js +27 -1
- package/dist/services/constants.js.map +1 -1
- package/dist/services/core/Err.js.map +1 -1
- package/dist/services/core/Utils.js +122 -25
- package/dist/services/core/Utils.js.map +1 -1
- package/dist/services/core/WebexRequest.js +6 -2
- package/dist/services/core/WebexRequest.js.map +1 -1
- package/dist/services/core/aqm-reqs.js +119 -30
- package/dist/services/core/aqm-reqs.js.map +1 -1
- package/dist/services/core/types.js.map +1 -1
- package/dist/services/core/websocket/WebSocketManager.js +22 -6
- package/dist/services/core/websocket/WebSocketManager.js.map +1 -1
- package/dist/services/core/websocket/connection-service.js +3 -1
- package/dist/services/core/websocket/connection-service.js.map +1 -1
- package/dist/services/core/websocket/types.js.map +1 -1
- package/dist/services/index.js +6 -0
- package/dist/services/index.js.map +1 -1
- package/dist/services/task/Task.js +754 -0
- package/dist/services/task/Task.js.map +1 -0
- package/dist/services/task/TaskFactory.js +49 -0
- package/dist/services/task/TaskFactory.js.map +1 -0
- package/dist/services/task/TaskManager.js +1073 -447
- package/dist/services/task/TaskManager.js.map +1 -1
- package/dist/services/task/TaskUtils.js +220 -23
- package/dist/services/task/TaskUtils.js.map +1 -1
- package/dist/services/task/WebexCallingUtils.js +70 -0
- package/dist/services/task/WebexCallingUtils.js.map +1 -0
- package/dist/services/task/constants.js +26 -2
- package/dist/services/task/constants.js.map +1 -1
- package/dist/services/task/contact.js +29 -0
- package/dist/services/task/contact.js.map +1 -1
- package/dist/services/task/dialer.js +129 -0
- package/dist/services/task/dialer.js.map +1 -1
- package/dist/services/task/digital/Digital.js +78 -0
- package/dist/services/task/digital/Digital.js.map +1 -0
- package/dist/services/task/state-machine/TaskStateMachine.js +971 -0
- package/dist/services/task/state-machine/TaskStateMachine.js.map +1 -0
- package/dist/services/task/state-machine/actions.js +572 -0
- package/dist/services/task/state-machine/actions.js.map +1 -0
- package/dist/services/task/state-machine/constants.js +161 -0
- package/dist/services/task/state-machine/constants.js.map +1 -0
- package/dist/services/task/state-machine/guards.js +409 -0
- package/dist/services/task/state-machine/guards.js.map +1 -0
- package/dist/services/task/state-machine/index.js +53 -0
- package/dist/services/task/state-machine/index.js.map +1 -0
- package/dist/services/task/state-machine/types.js +54 -0
- package/dist/services/task/state-machine/types.js.map +1 -0
- package/dist/services/task/state-machine/uiControlsComputer.js +703 -0
- package/dist/services/task/state-machine/uiControlsComputer.js.map +1 -0
- package/dist/services/task/taskDataNormalizer.js +99 -0
- package/dist/services/task/taskDataNormalizer.js.map +1 -0
- package/dist/services/task/types.js +243 -5
- package/dist/services/task/types.js.map +1 -1
- package/dist/services/task/voice/Voice.js +1380 -0
- package/dist/services/task/voice/Voice.js.map +1 -0
- package/dist/services/task/voice/WebRTC.js +152 -0
- package/dist/services/task/voice/WebRTC.js.map +1 -0
- package/dist/services/task/voice/wxAppVoiceMethods.js +201 -0
- package/dist/services/task/voice/wxAppVoiceMethods.js.map +1 -0
- package/dist/services/wxAppTelephonyUtils.js +19 -0
- package/dist/services/wxAppTelephonyUtils.js.map +1 -0
- package/dist/types/cc.d.ts +967 -0
- package/dist/types/config.d.ts +79 -0
- package/dist/types/constants.d.ts +74 -0
- package/dist/types/index.d.ts +201 -0
- package/dist/types/logger-proxy.d.ts +71 -0
- package/dist/types/metrics/MetricsManager.d.ts +223 -0
- package/dist/types/metrics/behavioral-events.d.ts +29 -0
- package/dist/types/metrics/constants.d.ts +183 -0
- package/dist/types/services/AddressBook.d.ts +75 -0
- package/dist/types/services/AnswerCallOnWebexService.d.ts +37 -0
- package/dist/types/services/ApiAiAssistant.d.ts +49 -0
- package/dist/types/services/EntryPoint.d.ts +69 -0
- package/dist/types/services/Queue.d.ts +78 -0
- package/dist/types/services/UserPreference.d.ts +118 -0
- package/dist/types/services/WebCallingService.d.ts +1 -0
- package/dist/types/services/WebexCrossClientService.d.ts +28 -0
- package/dist/types/services/WxAppTelephonyMercurySync.d.ts +28 -0
- package/dist/types/services/agent/index.d.ts +46 -0
- package/dist/types/services/agent/types.d.ts +413 -0
- package/dist/types/services/config/Util.d.ts +20 -0
- package/dist/types/services/config/constants.d.ts +273 -0
- package/dist/types/services/config/index.d.ts +177 -0
- package/dist/types/services/config/types.d.ts +1381 -0
- package/dist/types/services/constants.d.ts +110 -0
- package/dist/types/services/core/Err.d.ts +127 -0
- package/dist/types/services/core/GlobalTypes.d.ts +58 -0
- package/dist/types/services/core/Utils.d.ts +121 -0
- package/dist/types/services/core/WebexRequest.d.ts +23 -0
- package/dist/types/services/core/aqm-reqs.d.ts +65 -0
- package/dist/types/services/core/constants.d.ts +99 -0
- package/dist/types/services/core/types.d.ts +49 -0
- package/dist/types/services/core/websocket/WebSocketManager.d.ts +36 -0
- package/dist/types/services/core/websocket/connection-service.d.ts +27 -0
- package/dist/types/services/core/websocket/keepalive.worker.d.ts +2 -0
- package/dist/types/services/core/websocket/types.d.ts +37 -0
- package/dist/types/services/index.d.ts +54 -0
- package/dist/types/services/task/AutoWrapup.d.ts +40 -0
- package/dist/types/services/task/Task.d.ts +175 -0
- package/dist/types/services/task/TaskFactory.d.ts +13 -0
- package/dist/types/services/task/TaskManager.d.ts +1 -0
- package/dist/types/services/task/TaskUtils.d.ts +138 -0
- package/dist/types/services/task/WebexCallingUtils.d.ts +11 -0
- package/dist/types/services/task/constants.d.ts +94 -0
- package/dist/types/services/task/contact.d.ts +73 -0
- package/dist/types/services/task/dialer.d.ts +73 -0
- package/dist/types/services/task/digital/Digital.d.ts +22 -0
- package/dist/types/services/task/state-machine/TaskStateMachine.d.ts +1398 -0
- package/dist/types/services/task/state-machine/actions.d.ts +10 -0
- package/dist/types/services/task/state-machine/constants.d.ts +107 -0
- package/dist/types/services/task/state-machine/guards.d.ts +103 -0
- package/dist/types/services/task/state-machine/index.d.ts +13 -0
- package/dist/types/services/task/state-machine/types.d.ts +277 -0
- package/dist/types/services/task/state-machine/uiControlsComputer.d.ts +9 -0
- package/dist/types/services/task/taskDataNormalizer.d.ts +10 -0
- package/dist/types/services/task/types.d.ts +1933 -0
- package/dist/types/services/task/voice/Voice.d.ts +223 -0
- package/dist/types/services/task/voice/WebRTC.d.ts +53 -0
- package/dist/types/services/task/voice/wxAppVoiceMethods.d.ts +52 -0
- package/dist/types/services/wxAppTelephonyUtils.d.ts +5 -0
- package/dist/types/types.d.ts +784 -0
- package/dist/types/utils/PageCache.d.ts +190 -0
- package/dist/types/webex-config.d.ts +53 -0
- package/dist/types/webex.d.ts +8 -0
- package/dist/types.js +137 -3
- package/dist/types.js.map +1 -1
- package/dist/utils/PageCache.js +19 -5
- package/dist/utils/PageCache.js.map +1 -1
- package/dist/webex.js +14 -2
- package/dist/webex.js.map +1 -1
- package/package.json +16 -12
- package/src/cc.ts +983 -60
- package/src/config.ts +13 -0
- package/src/constants.ts +29 -1
- package/src/index.ts +26 -5
- package/src/metrics/ai-docs/AGENTS.md +350 -0
- package/src/metrics/ai-docs/ARCHITECTURE.md +338 -0
- package/src/metrics/ai-docs/metrics-spec.md +860 -0
- package/src/metrics/behavioral-events.ts +134 -0
- package/src/metrics/constants.ts +39 -3
- package/src/services/AddressBook.ts +17 -6
- package/src/services/AnswerCallOnWebexService.ts +206 -0
- package/src/services/ApiAiAssistant.ts +412 -0
- package/src/services/EntryPoint.ts +59 -60
- package/src/services/Queue.ts +29 -12
- package/src/services/UserPreference.ts +509 -0
- package/src/services/WebexCrossClientService.ts +212 -0
- package/src/services/WxAppTelephonyMercurySync.ts +115 -0
- package/src/services/agent/ai-docs/AGENTS.md +240 -0
- package/src/services/agent/ai-docs/ARCHITECTURE.md +304 -0
- package/src/services/agent/ai-docs/agent-spec.md +504 -0
- package/src/services/agent/types.ts +1 -1
- package/src/services/ai-docs/AGENTS.md +386 -0
- package/src/services/ai-docs/services-spec.md +497 -0
- package/src/services/config/Util.ts +13 -2
- package/src/services/config/ai-docs/AGENTS.md +255 -0
- package/src/services/config/ai-docs/ARCHITECTURE.md +426 -0
- package/src/services/config/ai-docs/config-spec.md +675 -0
- package/src/services/config/constants.ts +47 -7
- package/src/services/config/index.ts +45 -1
- package/src/services/config/types.ts +253 -11
- package/src/services/constants.ts +29 -0
- package/src/services/core/Err.ts +4 -0
- package/src/services/core/Utils.ts +143 -30
- package/src/services/core/WebexRequest.ts +3 -1
- package/src/services/core/ai-docs/AGENTS.md +381 -0
- package/src/services/core/ai-docs/ARCHITECTURE.md +698 -0
- package/src/services/core/ai-docs/core-spec.md +787 -0
- package/src/services/core/aqm-reqs.ts +125 -32
- package/src/services/core/types.ts +2 -0
- package/src/services/core/websocket/WebSocketManager.ts +23 -6
- package/src/services/core/websocket/connection-service.ts +5 -1
- package/src/services/core/websocket/types.ts +1 -1
- package/src/services/index.ts +4 -0
- package/src/services/task/Task.ts +908 -0
- package/src/services/task/TaskFactory.ts +60 -0
- package/src/services/task/TaskManager.ts +1291 -513
- package/src/services/task/TaskUtils.ts +314 -24
- package/src/services/task/WebexCallingUtils.ts +136 -0
- package/src/services/task/ai-docs/AGENTS.md +457 -0
- package/src/services/task/ai-docs/ARCHITECTURE.md +595 -0
- package/src/services/task/ai-docs/task-spec.md +1469 -0
- package/src/services/task/constants.ts +26 -0
- package/src/services/task/contact.ts +30 -0
- package/src/services/task/dialer.ts +136 -1
- package/src/services/task/digital/Digital.ts +97 -0
- package/src/services/task/state-machine/TaskStateMachine.ts +1313 -0
- package/src/services/task/state-machine/actions.ts +741 -0
- package/src/services/task/state-machine/ai-docs/AGENTS.md +462 -0
- package/src/services/task/state-machine/ai-docs/ARCHITECTURE.md +1146 -0
- package/src/services/task/state-machine/ai-docs/task-state-machine-spec.md +2209 -0
- package/src/services/task/state-machine/constants.ts +172 -0
- package/src/services/task/state-machine/guards.ts +498 -0
- package/src/services/task/state-machine/index.ts +28 -0
- package/src/services/task/state-machine/types.ts +258 -0
- package/src/services/task/state-machine/uiControlsComputer.ts +1135 -0
- package/src/services/task/taskDataNormalizer.ts +137 -0
- package/src/services/task/types.ts +843 -70
- package/src/services/task/voice/Voice.ts +1720 -0
- package/src/services/task/voice/WebRTC.ts +191 -0
- package/src/services/task/voice/wxAppVoiceMethods.ts +307 -0
- package/src/services/wxAppTelephonyUtils.ts +14 -0
- package/src/types.ts +238 -11
- package/src/utils/AGENTS.md +289 -0
- package/src/utils/PageCache.ts +38 -5
- package/src/utils/ai-docs/utils-spec.md +391 -0
- package/src/webex.js +2 -0
- package/test/unit/spec/cc.ts +1856 -122
- package/test/unit/spec/logger-proxy.ts +70 -0
- package/test/unit/spec/metrics/behavioral-events.ts +18 -0
- package/test/unit/spec/services/AddressBook.ts +37 -6
- package/test/unit/spec/services/AnswerCallOnWebexService.ts +223 -0
- package/test/unit/spec/services/ApiAiAssistant.ts +273 -0
- package/test/unit/spec/services/EntryPoint.ts +87 -40
- package/test/unit/spec/services/Queue.ts +123 -12
- package/test/unit/spec/services/UserPreference.ts +401 -0
- package/test/unit/spec/services/WebCallingService.ts +7 -1
- package/test/unit/spec/services/WebexCrossClientService.ts +261 -0
- package/test/unit/spec/services/WxAppTelephonyMercurySync.ts +113 -0
- package/test/unit/spec/services/config/Util.ts +85 -0
- package/test/unit/spec/services/config/index.ts +85 -29
- package/test/unit/spec/services/core/Utils.ts +481 -2
- package/test/unit/spec/services/core/WebexRequest.ts +3 -1
- package/test/unit/spec/services/core/aqm-reqs.ts +113 -1
- package/test/unit/spec/services/core/websocket/WebSocketManager.ts +137 -41
- package/test/unit/spec/services/core/websocket/connection-service.ts +3 -1
- package/test/unit/spec/services/task/AutoWrapup.ts +63 -0
- package/test/unit/spec/services/task/Task.ts +677 -0
- package/test/unit/spec/services/task/TaskFactory.ts +99 -0
- package/test/unit/spec/services/task/TaskManager.ts +2209 -918
- package/test/unit/spec/services/task/TaskUtils.ts +235 -0
- package/test/unit/spec/services/task/WebexCallingUtils.ts +153 -0
- package/test/unit/spec/services/task/contact.ts +33 -0
- package/test/unit/spec/services/task/dialer.ts +372 -96
- package/test/unit/spec/services/task/digital/Digital.ts +105 -0
- package/test/unit/spec/services/task/state-machine/TaskStateMachine.ts +3433 -0
- package/test/unit/spec/services/task/state-machine/guards.ts +839 -0
- package/test/unit/spec/services/task/state-machine/types.ts +18 -0
- package/test/unit/spec/services/task/state-machine/uiControlsComputer.ts +3101 -0
- package/test/unit/spec/services/task/taskTestUtils.ts +87 -0
- package/test/unit/spec/services/task/voice/Voice.ts +1523 -0
- package/test/unit/spec/services/task/voice/WebRTC.ts +235 -0
- package/test/unit/spec/services/task/voice/wxAppVoiceMethods.ts +459 -0
- package/umd/contact-center.min.js +2 -2
- package/umd/contact-center.min.js.map +1 -1
- package/dist/services/task/index.js +0 -1525
- package/dist/services/task/index.js.map +0 -1
- package/src/services/task/index.ts +0 -1801
- package/test/unit/spec/services/task/index.ts +0 -2184
package/src/types.ts
CHANGED
|
@@ -6,7 +6,12 @@ import {
|
|
|
6
6
|
} from '@webex/internal-plugin-metrics/src/metrics.types';
|
|
7
7
|
import * as Agent from './services/agent/types';
|
|
8
8
|
import * as Contact from './services/task/types';
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
AIFeatureFlags,
|
|
11
|
+
Profile,
|
|
12
|
+
CreateUserPreferenceRequest,
|
|
13
|
+
UpdateUserPreferenceRequest,
|
|
14
|
+
} from './services/config/types';
|
|
10
15
|
import {PaginatedResponse, BaseSearchParams} from './utils/PageCache';
|
|
11
16
|
|
|
12
17
|
/**
|
|
@@ -88,12 +93,19 @@ export type WebexRequestPayload = {
|
|
|
88
93
|
*/
|
|
89
94
|
type Listener = (e: string, data?: unknown) => void;
|
|
90
95
|
|
|
96
|
+
/**
|
|
97
|
+
* Mercury event handler callback.
|
|
98
|
+
* @internal
|
|
99
|
+
* @ignore
|
|
100
|
+
*/
|
|
101
|
+
type MercuryEventHandler = (data?: unknown) => void;
|
|
102
|
+
|
|
91
103
|
/**
|
|
92
104
|
* Event listener removal function type.
|
|
93
105
|
* @internal
|
|
94
106
|
* @ignore
|
|
95
107
|
*/
|
|
96
|
-
type ListenerOff = (e: string) => void;
|
|
108
|
+
type ListenerOff = (e: string, handler?: MercuryEventHandler) => void;
|
|
97
109
|
|
|
98
110
|
/**
|
|
99
111
|
* Service host configuration.
|
|
@@ -156,6 +168,10 @@ export interface CCPluginConfig {
|
|
|
156
168
|
};
|
|
157
169
|
/** Configuration for the calling client */
|
|
158
170
|
callingClientConfig: CallingClientConfig;
|
|
171
|
+
/** Whether to skip Mobius/WebRTC registration for browser login flows */
|
|
172
|
+
disableWebRTCRegistration?: boolean;
|
|
173
|
+
/** Whether wxApp Better Together (telephony REST + usersub) is enabled at init (WXCC-6026) */
|
|
174
|
+
enableWxBetterTogether?: boolean;
|
|
159
175
|
}
|
|
160
176
|
|
|
161
177
|
/**
|
|
@@ -286,6 +302,12 @@ interface IWebexInternal {
|
|
|
286
302
|
version: string;
|
|
287
303
|
/** Calling behavior configuration */
|
|
288
304
|
callingBehavior: string;
|
|
305
|
+
/** Whether the device is registered with WDM */
|
|
306
|
+
registered?: boolean;
|
|
307
|
+
/** Register the device with WDM */
|
|
308
|
+
register?: () => Promise<void>;
|
|
309
|
+
/** Unregister the device from WDM */
|
|
310
|
+
unregister?: () => Promise<void>;
|
|
289
311
|
};
|
|
290
312
|
/** Presence service */
|
|
291
313
|
presence: unknown;
|
|
@@ -295,6 +317,8 @@ interface IWebexInternal {
|
|
|
295
317
|
get: (service: string) => string;
|
|
296
318
|
/** Wait for service catalog to be loaded */
|
|
297
319
|
waitForCatalog: (service: string) => Promise<void>;
|
|
320
|
+
/** Check if current environment is INT (integration) */
|
|
321
|
+
isIntegrationEnvironment: () => boolean;
|
|
298
322
|
/** Host catalog for service discovery */
|
|
299
323
|
_hostCatalog: Record<string, ServiceHost[]>;
|
|
300
324
|
/** Service URLs cache */
|
|
@@ -539,22 +563,23 @@ export type RequestBody =
|
|
|
539
563
|
| Contact.ConsultTransferPayLoad
|
|
540
564
|
| Contact.cancelCtq
|
|
541
565
|
| Contact.WrapupPayLoad
|
|
542
|
-
| Contact.DialerPayload
|
|
566
|
+
| Contact.DialerPayload
|
|
567
|
+
| Contact.PreviewContactPayload
|
|
568
|
+
| CreateUserPreferenceRequest
|
|
569
|
+
| UpdateUserPreferenceRequest;
|
|
543
570
|
|
|
544
571
|
/**
|
|
545
572
|
* Represents the options to fetch buddy agents for the logged in agent.
|
|
546
|
-
* Buddy agents are other agents who can be consulted or
|
|
573
|
+
* Buddy agents are other agents who can be consulted or transferred to.
|
|
547
574
|
* @public
|
|
548
575
|
* @example
|
|
549
576
|
* const opts: BuddyAgents = { mediaType: 'telephony', state: 'Available' };
|
|
550
|
-
* @ignore
|
|
551
577
|
*/
|
|
552
578
|
export type BuddyAgents = {
|
|
553
579
|
/**
|
|
554
|
-
* The media type channel to filter buddy agents.
|
|
555
|
-
* Determines which channel capability the returned agents must have.
|
|
580
|
+
* The media type channel to filter buddy agents. Defaults to telephony when omitted.
|
|
556
581
|
*/
|
|
557
|
-
mediaType
|
|
582
|
+
mediaType?: 'telephony' | 'chat' | 'social' | 'email';
|
|
558
583
|
|
|
559
584
|
/**
|
|
560
585
|
* Optional filter for agent state.
|
|
@@ -562,9 +587,37 @@ export type BuddyAgents = {
|
|
|
562
587
|
* If omitted, returns both available and idle agents.
|
|
563
588
|
*/
|
|
564
589
|
state?: 'Available' | 'Idle';
|
|
590
|
+
|
|
591
|
+
/**
|
|
592
|
+
* Applies the default state policy for the operation. An explicit state takes precedence.
|
|
593
|
+
*/
|
|
594
|
+
action?: 'Consult' | 'Transfer';
|
|
595
|
+
};
|
|
596
|
+
|
|
597
|
+
/**
|
|
598
|
+
* Holds the configuration flags for the Agent.
|
|
599
|
+
* These flags determine the availability of certain features in the Agent UI.
|
|
600
|
+
* @internal
|
|
601
|
+
*/
|
|
602
|
+
export type ConfigFlags = {
|
|
603
|
+
isEndTaskEnabled: boolean;
|
|
604
|
+
isEndConsultEnabled: boolean;
|
|
605
|
+
webRtcEnabled: boolean;
|
|
606
|
+
autoWrapup: boolean;
|
|
607
|
+
aiFeature?: AIFeatureFlags;
|
|
608
|
+
/** Agent-profile policy used to derive task consult/transfer destination controls. */
|
|
609
|
+
consultTransfer?: Contact.ConsultTransferDestinationConfig;
|
|
610
|
+
/**
|
|
611
|
+
* Optional toggle to globally enable/disable recording controls.
|
|
612
|
+
* Falls back to backend hints when omitted.
|
|
613
|
+
*/
|
|
614
|
+
isRecordingEnabled?: boolean;
|
|
615
|
+
/** Whether wxApp thick-client answer controls/APIs are enabled (WXCC-6026) */
|
|
616
|
+
enableWxBetterTogether?: boolean;
|
|
565
617
|
};
|
|
566
618
|
|
|
567
619
|
/**
|
|
620
|
+
|
|
568
621
|
* Generic error structure for Contact Center SDK errors.
|
|
569
622
|
* Contains detailed information about the error context.
|
|
570
623
|
* @public
|
|
@@ -650,10 +703,12 @@ export interface AddressBookEntrySearchParams extends BaseSearchParams {
|
|
|
650
703
|
export interface EntryPointRecord {
|
|
651
704
|
id: string;
|
|
652
705
|
name: string;
|
|
706
|
+
/** Dialled number mapped to this entry point when included in the list response. */
|
|
707
|
+
number?: string;
|
|
653
708
|
description?: string;
|
|
654
|
-
type
|
|
655
|
-
isActive
|
|
656
|
-
orgId
|
|
709
|
+
type?: string;
|
|
710
|
+
isActive?: boolean;
|
|
711
|
+
orgId?: string;
|
|
657
712
|
createdAt?: string;
|
|
658
713
|
updatedAt?: string;
|
|
659
714
|
settings?: Record<string, any>;
|
|
@@ -817,3 +872,175 @@ export type BuddyAgentsResponse = Agent.BuddyAgentsSuccess | Error;
|
|
|
817
872
|
* function handleUpdateDeviceType(resp: UpdateDeviceTypeResponse) { ... }
|
|
818
873
|
*/
|
|
819
874
|
export type UpdateDeviceTypeResponse = Agent.DeviceTypeUpdateSuccess | Error;
|
|
875
|
+
|
|
876
|
+
/**
|
|
877
|
+
* Supported transcript control actions for AI Assistant events.
|
|
878
|
+
* @public
|
|
879
|
+
* @example
|
|
880
|
+
* const action: TranscriptAction = 'START';
|
|
881
|
+
* @ignore
|
|
882
|
+
*/
|
|
883
|
+
export type TranscriptAction = 'START' | 'STOP';
|
|
884
|
+
|
|
885
|
+
/**
|
|
886
|
+
* Parameters used to request AI Assistant real-time assistance.
|
|
887
|
+
* @public
|
|
888
|
+
* @example
|
|
889
|
+
* const params: RealTimeAssistanceParams = {
|
|
890
|
+
* interactionId: 'interaction-123',
|
|
891
|
+
* context: 'Need help with credit card payment due date',
|
|
892
|
+
* };
|
|
893
|
+
*/
|
|
894
|
+
export type RealTimeAssistanceParams = {
|
|
895
|
+
/** Agent identifier */
|
|
896
|
+
agentId: string;
|
|
897
|
+
/** Interaction identifier for which assistance should be generated */
|
|
898
|
+
interactionId: string;
|
|
899
|
+
/** Optional additional context that should refine the assistance */
|
|
900
|
+
context?: string;
|
|
901
|
+
/** Optional language code for assistance (for example, 'en'). Defaults to 'en'. */
|
|
902
|
+
languageCode?: string;
|
|
903
|
+
};
|
|
904
|
+
|
|
905
|
+
/**
|
|
906
|
+
* Supported user actions on an AI Assistant real-time assistance adaptive card.
|
|
907
|
+
* @public
|
|
908
|
+
*/
|
|
909
|
+
export const RealTimeAssistanceUserActionId = {
|
|
910
|
+
/** User liked the real-time assistance response */
|
|
911
|
+
LIKE: 'likeButton',
|
|
912
|
+
/** User disliked the real-time assistance response */
|
|
913
|
+
DISLIKE: 'dislikeButton',
|
|
914
|
+
/** User copied the real-time assistance response */
|
|
915
|
+
COPY: 'copyButton',
|
|
916
|
+
} as const;
|
|
917
|
+
|
|
918
|
+
/**
|
|
919
|
+
* Union type of supported real-time assistance user actions.
|
|
920
|
+
* @public
|
|
921
|
+
*/
|
|
922
|
+
export type RealTimeAssistanceUserActionId = Enum<typeof RealTimeAssistanceUserActionId>;
|
|
923
|
+
|
|
924
|
+
/**
|
|
925
|
+
* Parameters used to send user action feedback for a real-time assistance adaptive card.
|
|
926
|
+
* @public
|
|
927
|
+
* @example
|
|
928
|
+
* const params: RealTimeAssistanceUserActionParams = {
|
|
929
|
+
* agentId: 'agent-123',
|
|
930
|
+
* interactionId: 'interaction-123',
|
|
931
|
+
* adaptiveCardId: 'adaptive-card-123',
|
|
932
|
+
* actionId: RealTimeAssistanceUserActionId.LIKE,
|
|
933
|
+
* };
|
|
934
|
+
*/
|
|
935
|
+
export type RealTimeAssistanceUserActionParams = {
|
|
936
|
+
/** Agent identifier */
|
|
937
|
+
agentId: string;
|
|
938
|
+
/** Interaction identifier associated with the real-time assistance response */
|
|
939
|
+
interactionId: string;
|
|
940
|
+
/** Adaptive card identifier from the real-time assistance payload */
|
|
941
|
+
adaptiveCardId: string;
|
|
942
|
+
/** User action performed on the adaptive card */
|
|
943
|
+
actionId: RealTimeAssistanceUserActionId;
|
|
944
|
+
/** Optional language code. Defaults to 'en'. */
|
|
945
|
+
languageCode?: string;
|
|
946
|
+
};
|
|
947
|
+
|
|
948
|
+
/**
|
|
949
|
+
* Supported AI Assistant event categories.
|
|
950
|
+
* @public
|
|
951
|
+
* @example
|
|
952
|
+
* const eventType: AIAssistantEventType = AIAssistantEventType.CUSTOM_EVENT;
|
|
953
|
+
* @ignore
|
|
954
|
+
*/
|
|
955
|
+
export const AIAssistantEventType = {
|
|
956
|
+
/** Custom AI Assistant event */
|
|
957
|
+
CUSTOM_EVENT: 'CUSTOM_EVENT',
|
|
958
|
+
/** CTI-backed AI Assistant event */
|
|
959
|
+
CTI_EVENT: 'CTI_EVENT',
|
|
960
|
+
} as const;
|
|
961
|
+
|
|
962
|
+
/**
|
|
963
|
+
* Union type of AI Assistant event categories.
|
|
964
|
+
* @public
|
|
965
|
+
* @example
|
|
966
|
+
* function send(type: AIAssistantEventType) { ... }
|
|
967
|
+
* @ignore
|
|
968
|
+
*/
|
|
969
|
+
export type AIAssistantEventType = Enum<typeof AIAssistantEventType>;
|
|
970
|
+
|
|
971
|
+
/**
|
|
972
|
+
* Supported AI Assistant event names.
|
|
973
|
+
* @public
|
|
974
|
+
* @example
|
|
975
|
+
* const name: AIAssistantEventName = AIAssistantEventName.GET_TRANSCRIPTS;
|
|
976
|
+
* @ignore
|
|
977
|
+
*/
|
|
978
|
+
export const AIAssistantEventName = {
|
|
979
|
+
/** Request transcript streaming for an interaction */
|
|
980
|
+
GET_TRANSCRIPTS: 'GET_TRANSCRIPTS',
|
|
981
|
+
/** Request a suggested response for an interaction */
|
|
982
|
+
GET_SUGGESTIONS: 'GET_SUGGESTIONS',
|
|
983
|
+
/** Add extra context to refine a suggested response */
|
|
984
|
+
ADD_SUGGESTIONS_EXTRA_CONTEXT: 'ADD_SUGGESTIONS_EXTRA_CONTEXT',
|
|
985
|
+
/** Request mid-call summary generation */
|
|
986
|
+
GET_MID_CALL_SUMMARY: 'GET_MID_CALL_SUMMARY',
|
|
987
|
+
/** Request post-call summary generation */
|
|
988
|
+
GET_POST_CALL_SUMMARY: 'GET_POST_CALL_SUMMARY',
|
|
989
|
+
/** Mid-call summary response event */
|
|
990
|
+
MID_CALL_SUMMARY_RESPONSE: 'MID_CALL_SUMMARY_RESPONSE',
|
|
991
|
+
/** Post-call summary response event */
|
|
992
|
+
POST_CALL_SUMMARY_RESPONSE: 'POST_CALL_SUMMARY_RESPONSE',
|
|
993
|
+
/** Suggested digital response event */
|
|
994
|
+
SUGGESTED_RESPONSES_DIGITAL: 'SUGGESTED_RESPONSES_DIGITAL',
|
|
995
|
+
/** User action on a suggested response adaptive card */
|
|
996
|
+
SUGGESTED_RESPONSES_USER_ACTION: 'SUGGESTED_RESPONSES_USER_ACTION',
|
|
997
|
+
} as const;
|
|
998
|
+
|
|
999
|
+
/**
|
|
1000
|
+
* Union type of AI Assistant event names.
|
|
1001
|
+
* @public
|
|
1002
|
+
* @example
|
|
1003
|
+
* function handle(name: AIAssistantEventName) { ... }
|
|
1004
|
+
* @ignore
|
|
1005
|
+
*/
|
|
1006
|
+
export type AIAssistantEventName = Enum<typeof AIAssistantEventName>;
|
|
1007
|
+
|
|
1008
|
+
/**
|
|
1009
|
+
* A single transcript message entry returned by AI Assistant APIs.
|
|
1010
|
+
* @public
|
|
1011
|
+
* @example
|
|
1012
|
+
* const message: TranscriptMessage = { role: 'AGENT', content: 'Hello', messageId: '1', publishTimestamp: Date.now() };
|
|
1013
|
+
*
|
|
1014
|
+
*/
|
|
1015
|
+
export type TranscriptMessage = {
|
|
1016
|
+
/** Speaker role for this message */
|
|
1017
|
+
role: string;
|
|
1018
|
+
/** Transcript chunk content */
|
|
1019
|
+
content: string;
|
|
1020
|
+
/** Unique message identifier */
|
|
1021
|
+
messageId: string;
|
|
1022
|
+
/** Message publish timestamp (epoch milliseconds) */
|
|
1023
|
+
publishTimestamp: number;
|
|
1024
|
+
};
|
|
1025
|
+
|
|
1026
|
+
/**
|
|
1027
|
+
* Response payload for historic transcripts API.
|
|
1028
|
+
* @public
|
|
1029
|
+
* @example
|
|
1030
|
+
* const resp: HistoricTranscriptsResponse = { orgId: 'org', agentId: 'agent', conversationId: null, interactionId: 'int', source: 'AI', data: [] };
|
|
1031
|
+
*
|
|
1032
|
+
*/
|
|
1033
|
+
export type HistoricTranscriptsResponse = {
|
|
1034
|
+
/** Organization identifier */
|
|
1035
|
+
orgId: string;
|
|
1036
|
+
/** Agent identifier */
|
|
1037
|
+
agentId: string;
|
|
1038
|
+
/** Conversation identifier when available */
|
|
1039
|
+
conversationId: string | null;
|
|
1040
|
+
/** Interaction identifier */
|
|
1041
|
+
interactionId: string;
|
|
1042
|
+
/** Data source identifier */
|
|
1043
|
+
source: string;
|
|
1044
|
+
/** Transcript messages */
|
|
1045
|
+
data: TranscriptMessage[];
|
|
1046
|
+
};
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
# Utils
|
|
2
|
+
|
|
3
|
+
> **Legacy/reference-only.** Canonical SDD: [`ai-docs/utils-spec.md`](ai-docs/utils-spec.md). Use the package [manifest](../../.sdd/manifest.json) and [`SPEC_INDEX.md`](../../ai-docs/SPEC_INDEX.md) for routing; code and tests remain the behavioral referee.
|
|
4
|
+
>
|
|
5
|
+
> **Legacy scope:** This guide covers shared pagination/cache contracts used by data services. For repository rules and cross-service conventions, see the [root orchestrator AGENTS.md](../../AGENTS.md).
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Key Capabilities
|
|
10
|
+
|
|
11
|
+
The utils scope currently provides shared pagination and cache behavior for contact-center data services:
|
|
12
|
+
|
|
13
|
+
- **Typed Pagination Contracts**: Reusable interfaces for response metadata and query params
|
|
14
|
+
- **Generic In-Memory Page Caching**: `PageCache<T>` utility for simple pagination reuse
|
|
15
|
+
- **Cache Safety Rules**: Explicit bypass behavior for query variants and enabled result/response-shape flags
|
|
16
|
+
- **Spec-Driven Utility Workflow**: Utility-specific implementation and validation flow documented inline in this file
|
|
17
|
+
|
|
18
|
+
| Component | File | Description |
|
|
19
|
+
| --------------------- | -------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
20
|
+
| `PageCache` | [`PageCache.ts`](./PageCache.ts) | Generic in-memory cache utility for paginated API responses with TTL expiry and helper methods for key generation and cache eligibility checks. |
|
|
21
|
+
| `Pagination Types` | [`PageCache.ts`](./PageCache.ts) | `PaginationMeta`, `PaginatedResponse<T>`, `BaseSearchParams`, and `PageCacheEntry<T>` shared across data services. |
|
|
22
|
+
| `Pagination Defaults` | [`PageCache.ts`](./PageCache.ts) | `PAGINATION_DEFAULTS` (`PAGE`, `PAGE_SIZE`) used by services for consistent request defaults. |
|
|
23
|
+
| `Specs Workflow` | `AGENTS.md` (inline) | Mermaid flow for specs-driven utility changes, acceptance criteria, and drift checks. |
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## File Structure
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
src/utils/
|
|
31
|
+
├── AGENTS.md # This file: utils scope guide
|
|
32
|
+
└── PageCache.ts # Generic cache + pagination contracts/defaults
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## PageCache Utility
|
|
38
|
+
|
|
39
|
+
`PageCache<T>` provides a consistent caching model for paginated list APIs. It is optimized for simple page browsing and intentionally bypasses cache for parameterized query cases (`search`, `filter`, `attributes`, `sortBy`) and enabled result/response-shape flags (`desktopProfileFilter`, `provisioningView`, `singleObjectResponse`).
|
|
40
|
+
|
|
41
|
+
### Reference Usage
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
import PageCache, {PAGINATION_DEFAULTS} from '../utils/PageCache';
|
|
45
|
+
|
|
46
|
+
const cache = new PageCache<MyItem>('MyService');
|
|
47
|
+
|
|
48
|
+
const page = PAGINATION_DEFAULTS.PAGE;
|
|
49
|
+
const pageSize = PAGINATION_DEFAULTS.PAGE_SIZE;
|
|
50
|
+
const cacheKey = cache.buildCacheKey(scopeId, page, pageSize);
|
|
51
|
+
|
|
52
|
+
// Include every supported result- or response-shape-changing input.
|
|
53
|
+
const canUseCache = cache.canUseCache({
|
|
54
|
+
search,
|
|
55
|
+
filter,
|
|
56
|
+
attributes,
|
|
57
|
+
sortBy,
|
|
58
|
+
desktopProfileFilter,
|
|
59
|
+
provisioningView,
|
|
60
|
+
singleObjectResponse,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
if (canUseCache) {
|
|
64
|
+
const cachedEntry = cache.getCachedPage(cacheKey);
|
|
65
|
+
if (cachedEntry) {
|
|
66
|
+
return {
|
|
67
|
+
data: cachedEntry.data,
|
|
68
|
+
meta: {
|
|
69
|
+
page,
|
|
70
|
+
pageSize,
|
|
71
|
+
...cachedEntry.totalMeta,
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const response = await fetchPageFromApi();
|
|
78
|
+
|
|
79
|
+
if (canUseCache && response.data) {
|
|
80
|
+
cache.cachePage(cacheKey, response.data, response.meta);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return response;
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Cache Lifecycle
|
|
87
|
+
|
|
88
|
+
```mermaid
|
|
89
|
+
graph TD
|
|
90
|
+
A[Request arrives with scopeId/page/pageSize] --> B{canUseCache?}
|
|
91
|
+
B -->|No: query variant or enabled result/shape flag| C[Bypass cache and call API]
|
|
92
|
+
B -->|Yes| D[buildCacheKey scopeId:page:pageSize]
|
|
93
|
+
D --> E["getCachedPage(cacheKey)"]
|
|
94
|
+
E -->|Miss| C
|
|
95
|
+
E -->|Hit and not expired| F[Return cached data and totalMeta]
|
|
96
|
+
E -->|Hit but expired >= 5 minutes| G[Delete entry and treat as miss]
|
|
97
|
+
G --> C
|
|
98
|
+
C --> H[Receive API response]
|
|
99
|
+
H --> I["cachePage(cacheKey, data, meta)"]
|
|
100
|
+
I --> J[Return fresh response]
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## Public Contracts
|
|
106
|
+
|
|
107
|
+
All public contracts for utils are defined in [`PageCache.ts`](./PageCache.ts).
|
|
108
|
+
|
|
109
|
+
### `PaginationMeta`
|
|
110
|
+
|
|
111
|
+
Common pagination metadata used across list APIs.
|
|
112
|
+
|
|
113
|
+
| Field | Type | Notes |
|
|
114
|
+
| ----------------------------- | ------------------------ | ----------------------- |
|
|
115
|
+
| `orgid` | `string` | Organization identifier |
|
|
116
|
+
| `page` / `currentPage` | `number` | Current page aliases |
|
|
117
|
+
| `pageSize` | `number` | Items per page |
|
|
118
|
+
| `totalPages` | `number` | Total page count |
|
|
119
|
+
| `totalRecords` / `totalItems` | `number` | Total item aliases |
|
|
120
|
+
| `links` | `Record<string, string>` | Pagination link map |
|
|
121
|
+
|
|
122
|
+
### `PaginatedResponse<T>`
|
|
123
|
+
|
|
124
|
+
Canonical paginated response type:
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
interface PaginatedResponse<T> {
|
|
128
|
+
data: T[];
|
|
129
|
+
meta: PaginationMeta;
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### `PageCacheEntry<T>`
|
|
134
|
+
|
|
135
|
+
Shape of a cached page entry returned by `getCachedPage()`:
|
|
136
|
+
|
|
137
|
+
- `data: T[]`
|
|
138
|
+
- `timestamp: number` (epoch milliseconds)
|
|
139
|
+
- `totalMeta?: { totalPages?: number; totalRecords?: number }`
|
|
140
|
+
|
|
141
|
+
### `CacheValidationParams`
|
|
142
|
+
|
|
143
|
+
Contract passed to `canUseCache()`:
|
|
144
|
+
|
|
145
|
+
- `search?: string`
|
|
146
|
+
- `filter?: string`
|
|
147
|
+
- `attributes?: string`
|
|
148
|
+
- `sortBy?: string`
|
|
149
|
+
- `desktopProfileFilter?: boolean`
|
|
150
|
+
- `provisioningView?: boolean`
|
|
151
|
+
- `singleObjectResponse?: boolean`
|
|
152
|
+
|
|
153
|
+
Behavior note:
|
|
154
|
+
|
|
155
|
+
- Cache bypass is triggered by a truthy query variant or enabled result/response-shape flag; an explicit `false` boolean remains cache-compatible because it is semantically equivalent to omission.
|
|
156
|
+
- `sortOrder` is not a `CacheValidationParams` field. A service where it changes the wire order without `sortBy` must pass an effective `sortBy`; Queue normalizes a direction-only request to `sortBy: 'name'` before cache validation.
|
|
157
|
+
|
|
158
|
+
### `BaseSearchParams`
|
|
159
|
+
|
|
160
|
+
Common query parameter contract with pagination and sorting:
|
|
161
|
+
|
|
162
|
+
- `search`, `filter`, `attributes`
|
|
163
|
+
- `page`, `pageSize`
|
|
164
|
+
- `sortBy`, `sortOrder`
|
|
165
|
+
|
|
166
|
+
### `PAGINATION_DEFAULTS`
|
|
167
|
+
|
|
168
|
+
Standard defaults exported for callers:
|
|
169
|
+
|
|
170
|
+
- `PAGE: 0`
|
|
171
|
+
- `PAGE_SIZE: 100`
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
## PageCache API
|
|
176
|
+
|
|
177
|
+
### `constructor(apiName: string)`
|
|
178
|
+
|
|
179
|
+
Creates a typed cache instance and stores `apiName` for `LoggerProxy` context.
|
|
180
|
+
|
|
181
|
+
### `canUseCache(params: CacheValidationParams): boolean`
|
|
182
|
+
|
|
183
|
+
Returns `true` only when all of these are absent:
|
|
184
|
+
|
|
185
|
+
- `search`
|
|
186
|
+
- `filter`
|
|
187
|
+
- `attributes`
|
|
188
|
+
- `sortBy`
|
|
189
|
+
- `desktopProfileFilter`, `provisioningView`, or `singleObjectResponse` when `true`
|
|
190
|
+
|
|
191
|
+
An explicit `false` boolean remains eligible. `sortOrder` is normalized by the consuming service when it changes the effective wire order; Queue passes `sortBy: 'name'` for a direction-only request.
|
|
192
|
+
|
|
193
|
+
### `buildCacheKey(scopeId: string, page: number, pageSize: number): string`
|
|
194
|
+
|
|
195
|
+
Builds deterministic cache key format:
|
|
196
|
+
|
|
197
|
+
```text
|
|
198
|
+
${scopeId}:${page}:${pageSize}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### `getCachedPage(cacheKey: string): PageCacheEntry<T> | null`
|
|
202
|
+
|
|
203
|
+
Behavior:
|
|
204
|
+
|
|
205
|
+
1. Returns `null` if key not found
|
|
206
|
+
2. Computes cache age in minutes
|
|
207
|
+
3. If age is `>= 5`, logs expiry, deletes entry, returns `null`
|
|
208
|
+
4. Otherwise returns cached entry
|
|
209
|
+
|
|
210
|
+
### `cachePage(cacheKey: string, data: T[], meta?: any): void`
|
|
211
|
+
|
|
212
|
+
Stores entry with:
|
|
213
|
+
|
|
214
|
+
- `data`
|
|
215
|
+
- `timestamp`
|
|
216
|
+
- `totalMeta.totalPages`
|
|
217
|
+
- `totalMeta.totalRecords` mapped from `meta.totalRecords || meta.totalItems`
|
|
218
|
+
|
|
219
|
+
### `clearCache(): void`
|
|
220
|
+
|
|
221
|
+
Clears all entries and logs cleared entry count.
|
|
222
|
+
|
|
223
|
+
### `getCacheSize(): number`
|
|
224
|
+
|
|
225
|
+
Returns current in-memory entry count.
|
|
226
|
+
|
|
227
|
+
Note: `clearCache()` and `getCacheSize()` are available for future use and are not currently called by existing consumers.
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
## Consumer Map
|
|
232
|
+
|
|
233
|
+
Current consumers of `PageCache` and defaults:
|
|
234
|
+
|
|
235
|
+
| Consumer | File | Usage |
|
|
236
|
+
| ----------------------- | ---------------------------------------------------------- | ------------------------------------------------------------ |
|
|
237
|
+
| `AddressBook` | [`../services/AddressBook.ts`](../services/AddressBook.ts) | Caches paged address-book responses |
|
|
238
|
+
| `Queue` | [`../services/Queue.ts`](../services/Queue.ts) | Caches paged queue responses |
|
|
239
|
+
| `Public type contracts` | [`../types.ts`](../types.ts) | Re-exports pagination/search contracts into SDK-facing types |
|
|
240
|
+
|
|
241
|
+
Cross-scope mention:
|
|
242
|
+
|
|
243
|
+
- Services-layer docs reference utils caching contracts at [`../services/ai-docs/AGENTS.md`](../services/ai-docs/AGENTS.md).
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
|
|
247
|
+
## Spec-Driven Utility Changes
|
|
248
|
+
|
|
249
|
+
When changing `src/utils` behavior or contracts:
|
|
250
|
+
|
|
251
|
+
1. Follow the workflow diagram below
|
|
252
|
+
2. Define acceptance criteria for contract and runtime behavior
|
|
253
|
+
3. Verify cache TTL, bypass rules, and key schema
|
|
254
|
+
4. Validate no spec drift before shipping
|
|
255
|
+
|
|
256
|
+
```mermaid
|
|
257
|
+
flowchart TD
|
|
258
|
+
A[Change proposed in src/utils] --> B{Classify change scope}
|
|
259
|
+
B -->|Contract change| C[Document expected API/type behavior]
|
|
260
|
+
B -->|Runtime behavior change| D[Document cache behavior and TTL impact]
|
|
261
|
+
B -->|Both| C
|
|
262
|
+
C --> E[Update utils AGENTS.md contracts and consumer map]
|
|
263
|
+
D --> F[Validate cache key schema and bypass conditions]
|
|
264
|
+
E --> G[Run drift check against PageCache.ts and consumer services]
|
|
265
|
+
F --> G
|
|
266
|
+
G --> H{Behavior and docs aligned?}
|
|
267
|
+
H -->|No| I[Revise implementation/docs and re-validate]
|
|
268
|
+
I --> G
|
|
269
|
+
H -->|Yes| J[Prepare PR with acceptance criteria and evidence]
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
## Validation Checklist
|
|
275
|
+
|
|
276
|
+
- [ ] Public types remain backward-compatible or migration is documented
|
|
277
|
+
- [ ] `PAGINATION_DEFAULTS` changes are intentional and propagated to consumers
|
|
278
|
+
- [ ] Cache TTL behavior remains explicit and covered by tests
|
|
279
|
+
- [ ] `canUseCache()` bypass conditions are unchanged or intentionally updated
|
|
280
|
+
- [ ] `totalRecords`/`totalItems` mapping behavior is preserved
|
|
281
|
+
- [ ] Logging still uses `LoggerProxy` with `module` and `method`
|
|
282
|
+
- [ ] AddressBook/Queue cache integration remains correct; EntryPoint remains explicitly uncached
|
|
283
|
+
|
|
284
|
+
---
|
|
285
|
+
|
|
286
|
+
## Related
|
|
287
|
+
|
|
288
|
+
- [Root orchestrator AGENTS.md](../../AGENTS.md) - Task routing and critical package rules
|
|
289
|
+
- [PageCache implementation](./PageCache.ts)
|
package/src/utils/PageCache.ts
CHANGED
|
@@ -97,6 +97,12 @@ export interface CacheValidationParams {
|
|
|
97
97
|
attributes?: string;
|
|
98
98
|
/** Sort by parameter */
|
|
99
99
|
sortBy?: string;
|
|
100
|
+
/** Desktop-profile filtering changes the returned result set */
|
|
101
|
+
desktopProfileFilter?: boolean;
|
|
102
|
+
/** Provisioning-view filtering changes the returned result set */
|
|
103
|
+
provisioningView?: boolean;
|
|
104
|
+
/** Single-object response mode changes the response shape */
|
|
105
|
+
singleObjectResponse?: boolean;
|
|
100
106
|
}
|
|
101
107
|
|
|
102
108
|
/**
|
|
@@ -116,8 +122,18 @@ const DEFAULT_CACHE_TTL_MINUTES = 5;
|
|
|
116
122
|
* // Create a cache instance for a specific data type
|
|
117
123
|
* const cache = new PageCache<AddressBookEntry>('AddressBook');
|
|
118
124
|
*
|
|
119
|
-
* // Check if we can use cache
|
|
120
|
-
* if (
|
|
125
|
+
* // Check if we can use cache for the complete result/response-shape input set
|
|
126
|
+
* if (
|
|
127
|
+
* cache.canUseCache({
|
|
128
|
+
* search,
|
|
129
|
+
* filter,
|
|
130
|
+
* attributes,
|
|
131
|
+
* sortBy,
|
|
132
|
+
* desktopProfileFilter,
|
|
133
|
+
* provisioningView,
|
|
134
|
+
* singleObjectResponse,
|
|
135
|
+
* })
|
|
136
|
+
* ) {
|
|
121
137
|
* const cacheKey = cache.buildCacheKey(orgId, page, pageSize);
|
|
122
138
|
* const cachedPage = cache.getCachedPage(cacheKey);
|
|
123
139
|
*
|
|
@@ -145,15 +161,32 @@ export class PageCache<T> {
|
|
|
145
161
|
|
|
146
162
|
/**
|
|
147
163
|
* Checks if cache can be used for the given parameters.
|
|
148
|
-
* Cache is only used for simple pagination without
|
|
164
|
+
* Cache is only used for simple pagination without query variants or enabled
|
|
165
|
+
* result/response-shape flags.
|
|
149
166
|
* @param {CacheValidationParams} params - Parameters to validate
|
|
150
167
|
* @returns {boolean} True if cache can be used
|
|
151
168
|
* @public
|
|
152
169
|
*/
|
|
153
170
|
public canUseCache(params: CacheValidationParams): boolean {
|
|
154
|
-
const {
|
|
171
|
+
const {
|
|
172
|
+
search,
|
|
173
|
+
filter,
|
|
174
|
+
attributes,
|
|
175
|
+
sortBy,
|
|
176
|
+
desktopProfileFilter,
|
|
177
|
+
provisioningView,
|
|
178
|
+
singleObjectResponse,
|
|
179
|
+
} = params;
|
|
155
180
|
|
|
156
|
-
return
|
|
181
|
+
return (
|
|
182
|
+
!search &&
|
|
183
|
+
!filter &&
|
|
184
|
+
!attributes &&
|
|
185
|
+
!sortBy &&
|
|
186
|
+
!desktopProfileFilter &&
|
|
187
|
+
!provisioningView &&
|
|
188
|
+
!singleObjectResponse
|
|
189
|
+
);
|
|
157
190
|
}
|
|
158
191
|
|
|
159
192
|
/**
|