@lpextend/node-sdk 1.1.3 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +108 -1
- package/dist/index.d.ts +108 -1
- package/dist/index.js +99 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +99 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1414,6 +1414,72 @@ interface CBAllBotAgentsStatusQueryParams {
|
|
|
1414
1414
|
interface CBPCSBotsStatusQueryParams {
|
|
1415
1415
|
showBotsData?: boolean;
|
|
1416
1416
|
}
|
|
1417
|
+
/**
|
|
1418
|
+
* Event types for consumer query metrics
|
|
1419
|
+
*/
|
|
1420
|
+
type CBConsumerQueryEventType = 'EVENT_KB_ANSWERED' | 'EVENT_KB_UN_ANSWERED';
|
|
1421
|
+
/**
|
|
1422
|
+
* Consumer query metrics request parameters
|
|
1423
|
+
*/
|
|
1424
|
+
interface CBConsumerQueryMetricsParams {
|
|
1425
|
+
/** Start time in milliseconds since epoch */
|
|
1426
|
+
startTime: string | number;
|
|
1427
|
+
/** End time in milliseconds since epoch */
|
|
1428
|
+
endTime: string | number;
|
|
1429
|
+
/** Event types to retrieve */
|
|
1430
|
+
eventType: CBConsumerQueryEventType[];
|
|
1431
|
+
/** Knowledge Base ID */
|
|
1432
|
+
kbId: string;
|
|
1433
|
+
}
|
|
1434
|
+
/**
|
|
1435
|
+
* Individual consumer query metric record
|
|
1436
|
+
*/
|
|
1437
|
+
interface CBConsumerQueryMetric {
|
|
1438
|
+
/** Unique identifier for the metric */
|
|
1439
|
+
id?: string;
|
|
1440
|
+
/** The consumer's query */
|
|
1441
|
+
consumerQuery: string;
|
|
1442
|
+
/** Event type (answered or unanswered) */
|
|
1443
|
+
eventType: CBConsumerQueryEventType;
|
|
1444
|
+
/** Knowledge base ID */
|
|
1445
|
+
kbId: string;
|
|
1446
|
+
/** Timestamp of the query */
|
|
1447
|
+
timestamp: number;
|
|
1448
|
+
/** Article IDs that matched (for answered queries) */
|
|
1449
|
+
articleIds?: string[];
|
|
1450
|
+
/** Confidence score (for answered queries) */
|
|
1451
|
+
confidence?: number;
|
|
1452
|
+
/** Session/conversation ID */
|
|
1453
|
+
conversationId?: string;
|
|
1454
|
+
/** Additional metadata */
|
|
1455
|
+
metadata?: Record<string, unknown>;
|
|
1456
|
+
}
|
|
1457
|
+
/**
|
|
1458
|
+
* Response from consumer query metrics API
|
|
1459
|
+
*/
|
|
1460
|
+
interface CBConsumerQueryMetricsResponse {
|
|
1461
|
+
/** Array of query metrics */
|
|
1462
|
+
data: CBConsumerQueryMetric[];
|
|
1463
|
+
/** Total count of records */
|
|
1464
|
+
totalCount?: number;
|
|
1465
|
+
/** Whether more records exist */
|
|
1466
|
+
hasMore?: boolean;
|
|
1467
|
+
}
|
|
1468
|
+
/**
|
|
1469
|
+
* Extended query params for date ranges > 7 days
|
|
1470
|
+
*/
|
|
1471
|
+
interface CBConsumerQueryMetricsExtendedParams {
|
|
1472
|
+
/** Start date (Date object or timestamp) */
|
|
1473
|
+
startDate: Date | number;
|
|
1474
|
+
/** End date (Date object or timestamp) */
|
|
1475
|
+
endDate: Date | number;
|
|
1476
|
+
/** Event types to retrieve */
|
|
1477
|
+
eventType: CBConsumerQueryEventType[];
|
|
1478
|
+
/** Knowledge Base ID */
|
|
1479
|
+
kbId: string;
|
|
1480
|
+
/** Optional progress callback */
|
|
1481
|
+
onProgress?: (completed: number, total: number) => void;
|
|
1482
|
+
}
|
|
1417
1483
|
|
|
1418
1484
|
/**
|
|
1419
1485
|
* AI Studio Types
|
|
@@ -3520,6 +3586,47 @@ declare class KnowledgeBasesAPI {
|
|
|
3520
3586
|
* Get default prompt for KAI
|
|
3521
3587
|
*/
|
|
3522
3588
|
getDefaultPrompt(): Promise<unknown>;
|
|
3589
|
+
/**
|
|
3590
|
+
* Get consumer query metrics for a knowledge base
|
|
3591
|
+
*
|
|
3592
|
+
* Retrieves answered and/or unanswered query metrics within a date range.
|
|
3593
|
+
* Note: The API only supports 7-day ranges. For longer ranges, use getConsumerQueryMetricsExtended().
|
|
3594
|
+
*
|
|
3595
|
+
* @param params - Query parameters including kbId, startTime, endTime, and eventType
|
|
3596
|
+
* @returns Promise resolving to consumer query metrics
|
|
3597
|
+
*
|
|
3598
|
+
* @example
|
|
3599
|
+
* ```typescript
|
|
3600
|
+
* const metrics = await sdk.conversationBuilder.knowledgeBases.getConsumerQueryMetrics({
|
|
3601
|
+
* kbId: 'kb-123',
|
|
3602
|
+
* startTime: Date.now() - 7 * 24 * 60 * 60 * 1000, // 7 days ago
|
|
3603
|
+
* endTime: Date.now(),
|
|
3604
|
+
* eventType: ['EVENT_KB_UN_ANSWERED'],
|
|
3605
|
+
* });
|
|
3606
|
+
* ```
|
|
3607
|
+
*/
|
|
3608
|
+
getConsumerQueryMetrics(params: CBConsumerQueryMetricsParams): Promise<CBConsumerQueryMetricsResponse>;
|
|
3609
|
+
/**
|
|
3610
|
+
* Get consumer query metrics for extended date ranges (up to 3 months)
|
|
3611
|
+
*
|
|
3612
|
+
* Automatically iterates through 7-day chunks to retrieve all metrics within
|
|
3613
|
+
* the specified date range. Useful for historical analysis beyond the 7-day API limit.
|
|
3614
|
+
*
|
|
3615
|
+
* @param params - Extended query parameters including startDate, endDate, kbId, and eventType
|
|
3616
|
+
* @returns Promise resolving to aggregated consumer query metrics from all chunks
|
|
3617
|
+
*
|
|
3618
|
+
* @example
|
|
3619
|
+
* ```typescript
|
|
3620
|
+
* const metrics = await sdk.conversationBuilder.knowledgeBases.getConsumerQueryMetricsExtended({
|
|
3621
|
+
* kbId: 'kb-123',
|
|
3622
|
+
* startDate: new Date('2024-01-01'),
|
|
3623
|
+
* endDate: new Date('2024-03-01'),
|
|
3624
|
+
* eventType: ['EVENT_KB_ANSWERED', 'EVENT_KB_UN_ANSWERED'],
|
|
3625
|
+
* onProgress: (completed, total) => console.log(`${completed}/${total} chunks processed`),
|
|
3626
|
+
* });
|
|
3627
|
+
* ```
|
|
3628
|
+
*/
|
|
3629
|
+
getConsumerQueryMetricsExtended(params: CBConsumerQueryMetricsExtendedParams): Promise<CBConsumerQueryMetric[]>;
|
|
3523
3630
|
}
|
|
3524
3631
|
/**
|
|
3525
3632
|
* Bot Agents API
|
|
@@ -3999,4 +4106,4 @@ type Scope = (typeof Scopes)[keyof typeof Scopes];
|
|
|
3999
4106
|
*/
|
|
4000
4107
|
declare function getShellToken(config: ShellTokenConfig): Promise<ShellTokenResponse>;
|
|
4001
4108
|
|
|
4002
|
-
export { type CreateConversationRequest$1 as AICreateConversationRequest, AIStudioAPI, type AIStudioCategory, type AIStudioConversation, type AIStudioFlow, type AIStudioMessage, type AIStudioSimulation, type AIStudioSummary, type AIStudioUser, AIStudioUsersAPI, type UpdateConversationRequest as AIUpdateConversationRequest, type APIResponse, type ActivityRecord, type AgentActivity, AgentActivityAPI, type AgentActivityQuery, AgentGroupsAPI, type AgentMetrics, AgentMetricsAPI, type AgentMetricsQuery, type AgentParticipant, type AgentStatus, type ApiKeyAuthResponse, AutomaticMessagesAPI, type BatchSummaryRequest, BotAgentsAPI, BotGroupsAPI, BotsAPI, type CBAddBotAgentRequest, type CBAllBotAgentsStatusQueryParams, type CBApiResponse, type CBAuthCredentials, type CBAuthInfo, type CBBot, type CBBotEnvironment, type CBBotGroup, type CBBotGroupsQueryParams, type CBBotInstanceStatus, type CBBotPlatform, type CBBotUser, type CBBotsByGroupQueryParams, type CBChatBot, type CBChatBotMetrics, type CBChatBotPlatformUser, type CBChatBotSummary, type CBChatBotSummaryList, type CBCredential, type CBDialog, type CBDialogGroup, type CBDialogTemplateSummary, type CBDomainList, type CBDuplicatePhrase, type CBDuplicatePhrases, type CBGlobalFunctions, type CBIntent, type CBInteraction, type CBInteractionContent, type CBInteractionList, type CBKAIOnDemandConfig, type CBKAISearchRequest, type CBKAISearchResponse, type CBKAISearchResultItem, type CBKBArticle, type CBKBArticlesQueryParams, type CBKBContentSource, type CBKBLandingPageMetrics, type CBKnowledgeBase, type CBKnowledgeBaseDetail, type CBKnowledgeBaseList, type CBLPAppCredentials, type CBLPSkill, type CBNLUDomain, type CBPCSBotsStatusQueryParams, type CBPageContext, type CBPaginatedResult, type CBResponder, type CBResponseMatch, type CBSuccessResult, type CBSyncStatusDetails, type CBTileData, CampaignsAPI, CategoriesAPI, type CloseConversationRequest, type CoBrowseSession, ConnectToMessagingAPI, type ConsumerParticipant, type ConsumerProfile, type ContentToRetrieve, ConversationBuilderAPI, type ConversationContext, type ConversationInteraction, type ConversationParticipant, type ConversationQueryParams, type ConversationSummary, type ConversationTransfer, ConversationsAPI, type CreateAIStudioUserRequest, type CreateAgentGroupRequest, type CreateAutomaticMessageRequest, type CreateCampaignRequest, type CreateCategoryRequest, type CreateConversationResponse, type CreateEngagementRequest, type CreateLOBRequest, type CreateLPPromptRequest, type CreatePredefinedContentRequest, type CreateProfileRequest, type CreatePromptRequest, type CreateSimulationRequest, type CreateSkillRequest, type CreateSpecialOccasionRequest, type CreateTranscriptAnalysisRequest, type CreateUserRequest, type CreateWorkingHoursRequest, DialogsAPI, EngagementsAPI, type ErrorCode, ErrorCodes, EvaluatorsAPI, type FileMessage, FlowsAPI, type GeneratedQuestion, type GeneratedRoute, GeneratorsAPI, type GuidedRoute, type GuidedRoutingEvaluationRequest, type GuidedRoutingEvaluationResponse, IntegrationsAPI, InteractionsAPI, type InvokeFlowRequest, type InvokeFlowResponse, type KAIRouteGenerationStatus, type KAIRouteGeneratorRequest, type KAIRouteGeneratorResponse, KnowledgeBasesAPI, type Knowledgebase, type KnowledgebaseHealth, type KnowledgebaseItem, type KnowledgebaseSearchRequest, type KnowledgebaseSearchResult, type KnowledgebaseTextItem, KnowledgebasesAPI, type LLMModel, type LLMProvider, LOBsAPI, type LPAgentGroup, type LPAutomaticMessage, type LPAutomaticMessageData, type LPCampaign, type LPEngagement, LPExtendSDK, type LPExtendSDKConfig, LPExtendSDKError, type LPLLMProviderModels, type LPLLMProviderSubscription, type LPLLMType, type LPLOB, type LPPermission, type LPPredefinedContent, type LPPredefinedContentData, type LPProfile, type LPPrompt, type LPPromptClientConfig, type LPPromptClientType, type LPPromptConfiguration, type LPPromptGenericConfig, type LPPromptStatus, type LPPromptVariable, type LPPromptVariableSourceType, type LPPromptVersionDetail, LPPromptsAPI, type LPPromptsQueryParams, type LPShift, type LPSkill, type LPSkillRoutingConfig, type LPSpecialOccasion, type LPSpecialOccasionEvent, type LPUser, type LPWorkingDay, type LPWorkingHours, type MemberOf, type MessageData, type MessageRecord, MessagingAPI, type MessagingConversation, type CreateConversationRequest as MessagingCreateConversationRequest, MessagingHistoryAPI, type MessagingHistoryQuery, type MessagingHistoryResponse, type MessagingInteraction, MessagingOperationsAPI, NLUDomainsAPI, type OutboundCampaignReport, type OutboundReportQuery, OutboundReportingAPI, type PaginatedResponse, PredefinedContentAPI, ProfilesAPI, type Prompt, PromptLibraryAPI, type PromptVariable, QueryAPI, type QueryGenerateRequest, type QueryGenerateResponse, type QuestionGeneratorRequest, type QuestionGeneratorResponse, type ResolutionEvaluationRequest, type ResolutionEvaluationResponse, type RichContentMessage, type SDEEvent, type SDERecord, type SDKInitResult, type Scope, Scopes, type SendMessageRequest, SentinelAPI, type SentinelAppSetting, type SentinelAppSettings, type SentinelAppUser, type SentinelAuthRequest, type SentinelCCUser, type SentinelDomainsResponse, type SentinelLoginUrlResponse, type SentinelLpToken, type SentinelLpUser, type SentinelManagerOf, type SentinelMemberOf, type SentinelProfile, type SentinelToken, type SentinelTokenExchange, type SentinelUserData, type SentinelUserSkill, type ShellTokenConfig, type ShellTokenResponse, type ShellTokenUser, type SimilarityEvaluationRequest, type SimilarityEvaluationResponse, type SimulationConfig, type SimulationJobResult, type SimulationQueryParams, type SimulationResults, type SimulationTestCase, SimulationsAPI, SkillsAPI, SpecialOccasionsAPI, SummaryAPI, type SummaryRequest, type SurveyRecord, type TextMessage, type TranscriptAnalysis, TranscriptAnalysisAPI, type TranscriptConversation, type TranscriptQuestion, type TransferConversationRequest, type UpdateAIStudioUserModelsRequest, type UpdateAIStudioUserRequest, type UpdateAgentGroupRequest, type UpdateAutomaticMessageRequest, type UpdateCampaignRequest, type UpdateCategoryRequest, type UpdateConversationAttributesRequest, type UpdateEngagementRequest, type UpdateLOBRequest, type UpdateLPPromptRequest, type UpdatePredefinedContentRequest, type UpdateProfileRequest, type UpdatePromptRequest, type UpdateSimulationRequest, type UpdateSkillRequest, type UpdateSpecialOccasionRequest, type UpdateTranscriptAnalysisRequest, type UpdateUserRequest, type UpdateWorkingHoursRequest, UsersAPI, VERSION, WorkingHoursAPI, createSDK, createSDKFromEnv, getShellToken, initializeSDK };
|
|
4109
|
+
export { type CreateConversationRequest$1 as AICreateConversationRequest, AIStudioAPI, type AIStudioCategory, type AIStudioConversation, type AIStudioFlow, type AIStudioMessage, type AIStudioSimulation, type AIStudioSummary, type AIStudioUser, AIStudioUsersAPI, type UpdateConversationRequest as AIUpdateConversationRequest, type APIResponse, type ActivityRecord, type AgentActivity, AgentActivityAPI, type AgentActivityQuery, AgentGroupsAPI, type AgentMetrics, AgentMetricsAPI, type AgentMetricsQuery, type AgentParticipant, type AgentStatus, type ApiKeyAuthResponse, AutomaticMessagesAPI, type BatchSummaryRequest, BotAgentsAPI, BotGroupsAPI, BotsAPI, type CBAddBotAgentRequest, type CBAllBotAgentsStatusQueryParams, type CBApiResponse, type CBAuthCredentials, type CBAuthInfo, type CBBot, type CBBotEnvironment, type CBBotGroup, type CBBotGroupsQueryParams, type CBBotInstanceStatus, type CBBotPlatform, type CBBotUser, type CBBotsByGroupQueryParams, type CBChatBot, type CBChatBotMetrics, type CBChatBotPlatformUser, type CBChatBotSummary, type CBChatBotSummaryList, type CBConsumerQueryEventType, type CBConsumerQueryMetric, type CBConsumerQueryMetricsExtendedParams, type CBConsumerQueryMetricsParams, type CBConsumerQueryMetricsResponse, type CBCredential, type CBDialog, type CBDialogGroup, type CBDialogTemplateSummary, type CBDomainList, type CBDuplicatePhrase, type CBDuplicatePhrases, type CBGlobalFunctions, type CBIntent, type CBInteraction, type CBInteractionContent, type CBInteractionList, type CBKAIOnDemandConfig, type CBKAISearchRequest, type CBKAISearchResponse, type CBKAISearchResultItem, type CBKBArticle, type CBKBArticlesQueryParams, type CBKBContentSource, type CBKBLandingPageMetrics, type CBKnowledgeBase, type CBKnowledgeBaseDetail, type CBKnowledgeBaseList, type CBLPAppCredentials, type CBLPSkill, type CBNLUDomain, type CBPCSBotsStatusQueryParams, type CBPageContext, type CBPaginatedResult, type CBResponder, type CBResponseMatch, type CBSuccessResult, type CBSyncStatusDetails, type CBTileData, CampaignsAPI, CategoriesAPI, type CloseConversationRequest, type CoBrowseSession, ConnectToMessagingAPI, type ConsumerParticipant, type ConsumerProfile, type ContentToRetrieve, ConversationBuilderAPI, type ConversationContext, type ConversationInteraction, type ConversationParticipant, type ConversationQueryParams, type ConversationSummary, type ConversationTransfer, ConversationsAPI, type CreateAIStudioUserRequest, type CreateAgentGroupRequest, type CreateAutomaticMessageRequest, type CreateCampaignRequest, type CreateCategoryRequest, type CreateConversationResponse, type CreateEngagementRequest, type CreateLOBRequest, type CreateLPPromptRequest, type CreatePredefinedContentRequest, type CreateProfileRequest, type CreatePromptRequest, type CreateSimulationRequest, type CreateSkillRequest, type CreateSpecialOccasionRequest, type CreateTranscriptAnalysisRequest, type CreateUserRequest, type CreateWorkingHoursRequest, DialogsAPI, EngagementsAPI, type ErrorCode, ErrorCodes, EvaluatorsAPI, type FileMessage, FlowsAPI, type GeneratedQuestion, type GeneratedRoute, GeneratorsAPI, type GuidedRoute, type GuidedRoutingEvaluationRequest, type GuidedRoutingEvaluationResponse, IntegrationsAPI, InteractionsAPI, type InvokeFlowRequest, type InvokeFlowResponse, type KAIRouteGenerationStatus, type KAIRouteGeneratorRequest, type KAIRouteGeneratorResponse, KnowledgeBasesAPI, type Knowledgebase, type KnowledgebaseHealth, type KnowledgebaseItem, type KnowledgebaseSearchRequest, type KnowledgebaseSearchResult, type KnowledgebaseTextItem, KnowledgebasesAPI, type LLMModel, type LLMProvider, LOBsAPI, type LPAgentGroup, type LPAutomaticMessage, type LPAutomaticMessageData, type LPCampaign, type LPEngagement, LPExtendSDK, type LPExtendSDKConfig, LPExtendSDKError, type LPLLMProviderModels, type LPLLMProviderSubscription, type LPLLMType, type LPLOB, type LPPermission, type LPPredefinedContent, type LPPredefinedContentData, type LPProfile, type LPPrompt, type LPPromptClientConfig, type LPPromptClientType, type LPPromptConfiguration, type LPPromptGenericConfig, type LPPromptStatus, type LPPromptVariable, type LPPromptVariableSourceType, type LPPromptVersionDetail, LPPromptsAPI, type LPPromptsQueryParams, type LPShift, type LPSkill, type LPSkillRoutingConfig, type LPSpecialOccasion, type LPSpecialOccasionEvent, type LPUser, type LPWorkingDay, type LPWorkingHours, type MemberOf, type MessageData, type MessageRecord, MessagingAPI, type MessagingConversation, type CreateConversationRequest as MessagingCreateConversationRequest, MessagingHistoryAPI, type MessagingHistoryQuery, type MessagingHistoryResponse, type MessagingInteraction, MessagingOperationsAPI, NLUDomainsAPI, type OutboundCampaignReport, type OutboundReportQuery, OutboundReportingAPI, type PaginatedResponse, PredefinedContentAPI, ProfilesAPI, type Prompt, PromptLibraryAPI, type PromptVariable, QueryAPI, type QueryGenerateRequest, type QueryGenerateResponse, type QuestionGeneratorRequest, type QuestionGeneratorResponse, type ResolutionEvaluationRequest, type ResolutionEvaluationResponse, type RichContentMessage, type SDEEvent, type SDERecord, type SDKInitResult, type Scope, Scopes, type SendMessageRequest, SentinelAPI, type SentinelAppSetting, type SentinelAppSettings, type SentinelAppUser, type SentinelAuthRequest, type SentinelCCUser, type SentinelDomainsResponse, type SentinelLoginUrlResponse, type SentinelLpToken, type SentinelLpUser, type SentinelManagerOf, type SentinelMemberOf, type SentinelProfile, type SentinelToken, type SentinelTokenExchange, type SentinelUserData, type SentinelUserSkill, type ShellTokenConfig, type ShellTokenResponse, type ShellTokenUser, type SimilarityEvaluationRequest, type SimilarityEvaluationResponse, type SimulationConfig, type SimulationJobResult, type SimulationQueryParams, type SimulationResults, type SimulationTestCase, SimulationsAPI, SkillsAPI, SpecialOccasionsAPI, SummaryAPI, type SummaryRequest, type SurveyRecord, type TextMessage, type TranscriptAnalysis, TranscriptAnalysisAPI, type TranscriptConversation, type TranscriptQuestion, type TransferConversationRequest, type UpdateAIStudioUserModelsRequest, type UpdateAIStudioUserRequest, type UpdateAgentGroupRequest, type UpdateAutomaticMessageRequest, type UpdateCampaignRequest, type UpdateCategoryRequest, type UpdateConversationAttributesRequest, type UpdateEngagementRequest, type UpdateLOBRequest, type UpdateLPPromptRequest, type UpdatePredefinedContentRequest, type UpdateProfileRequest, type UpdatePromptRequest, type UpdateSimulationRequest, type UpdateSkillRequest, type UpdateSpecialOccasionRequest, type UpdateTranscriptAnalysisRequest, type UpdateUserRequest, type UpdateWorkingHoursRequest, UsersAPI, VERSION, WorkingHoursAPI, createSDK, createSDKFromEnv, getShellToken, initializeSDK };
|
package/dist/index.d.ts
CHANGED
|
@@ -1414,6 +1414,72 @@ interface CBAllBotAgentsStatusQueryParams {
|
|
|
1414
1414
|
interface CBPCSBotsStatusQueryParams {
|
|
1415
1415
|
showBotsData?: boolean;
|
|
1416
1416
|
}
|
|
1417
|
+
/**
|
|
1418
|
+
* Event types for consumer query metrics
|
|
1419
|
+
*/
|
|
1420
|
+
type CBConsumerQueryEventType = 'EVENT_KB_ANSWERED' | 'EVENT_KB_UN_ANSWERED';
|
|
1421
|
+
/**
|
|
1422
|
+
* Consumer query metrics request parameters
|
|
1423
|
+
*/
|
|
1424
|
+
interface CBConsumerQueryMetricsParams {
|
|
1425
|
+
/** Start time in milliseconds since epoch */
|
|
1426
|
+
startTime: string | number;
|
|
1427
|
+
/** End time in milliseconds since epoch */
|
|
1428
|
+
endTime: string | number;
|
|
1429
|
+
/** Event types to retrieve */
|
|
1430
|
+
eventType: CBConsumerQueryEventType[];
|
|
1431
|
+
/** Knowledge Base ID */
|
|
1432
|
+
kbId: string;
|
|
1433
|
+
}
|
|
1434
|
+
/**
|
|
1435
|
+
* Individual consumer query metric record
|
|
1436
|
+
*/
|
|
1437
|
+
interface CBConsumerQueryMetric {
|
|
1438
|
+
/** Unique identifier for the metric */
|
|
1439
|
+
id?: string;
|
|
1440
|
+
/** The consumer's query */
|
|
1441
|
+
consumerQuery: string;
|
|
1442
|
+
/** Event type (answered or unanswered) */
|
|
1443
|
+
eventType: CBConsumerQueryEventType;
|
|
1444
|
+
/** Knowledge base ID */
|
|
1445
|
+
kbId: string;
|
|
1446
|
+
/** Timestamp of the query */
|
|
1447
|
+
timestamp: number;
|
|
1448
|
+
/** Article IDs that matched (for answered queries) */
|
|
1449
|
+
articleIds?: string[];
|
|
1450
|
+
/** Confidence score (for answered queries) */
|
|
1451
|
+
confidence?: number;
|
|
1452
|
+
/** Session/conversation ID */
|
|
1453
|
+
conversationId?: string;
|
|
1454
|
+
/** Additional metadata */
|
|
1455
|
+
metadata?: Record<string, unknown>;
|
|
1456
|
+
}
|
|
1457
|
+
/**
|
|
1458
|
+
* Response from consumer query metrics API
|
|
1459
|
+
*/
|
|
1460
|
+
interface CBConsumerQueryMetricsResponse {
|
|
1461
|
+
/** Array of query metrics */
|
|
1462
|
+
data: CBConsumerQueryMetric[];
|
|
1463
|
+
/** Total count of records */
|
|
1464
|
+
totalCount?: number;
|
|
1465
|
+
/** Whether more records exist */
|
|
1466
|
+
hasMore?: boolean;
|
|
1467
|
+
}
|
|
1468
|
+
/**
|
|
1469
|
+
* Extended query params for date ranges > 7 days
|
|
1470
|
+
*/
|
|
1471
|
+
interface CBConsumerQueryMetricsExtendedParams {
|
|
1472
|
+
/** Start date (Date object or timestamp) */
|
|
1473
|
+
startDate: Date | number;
|
|
1474
|
+
/** End date (Date object or timestamp) */
|
|
1475
|
+
endDate: Date | number;
|
|
1476
|
+
/** Event types to retrieve */
|
|
1477
|
+
eventType: CBConsumerQueryEventType[];
|
|
1478
|
+
/** Knowledge Base ID */
|
|
1479
|
+
kbId: string;
|
|
1480
|
+
/** Optional progress callback */
|
|
1481
|
+
onProgress?: (completed: number, total: number) => void;
|
|
1482
|
+
}
|
|
1417
1483
|
|
|
1418
1484
|
/**
|
|
1419
1485
|
* AI Studio Types
|
|
@@ -3520,6 +3586,47 @@ declare class KnowledgeBasesAPI {
|
|
|
3520
3586
|
* Get default prompt for KAI
|
|
3521
3587
|
*/
|
|
3522
3588
|
getDefaultPrompt(): Promise<unknown>;
|
|
3589
|
+
/**
|
|
3590
|
+
* Get consumer query metrics for a knowledge base
|
|
3591
|
+
*
|
|
3592
|
+
* Retrieves answered and/or unanswered query metrics within a date range.
|
|
3593
|
+
* Note: The API only supports 7-day ranges. For longer ranges, use getConsumerQueryMetricsExtended().
|
|
3594
|
+
*
|
|
3595
|
+
* @param params - Query parameters including kbId, startTime, endTime, and eventType
|
|
3596
|
+
* @returns Promise resolving to consumer query metrics
|
|
3597
|
+
*
|
|
3598
|
+
* @example
|
|
3599
|
+
* ```typescript
|
|
3600
|
+
* const metrics = await sdk.conversationBuilder.knowledgeBases.getConsumerQueryMetrics({
|
|
3601
|
+
* kbId: 'kb-123',
|
|
3602
|
+
* startTime: Date.now() - 7 * 24 * 60 * 60 * 1000, // 7 days ago
|
|
3603
|
+
* endTime: Date.now(),
|
|
3604
|
+
* eventType: ['EVENT_KB_UN_ANSWERED'],
|
|
3605
|
+
* });
|
|
3606
|
+
* ```
|
|
3607
|
+
*/
|
|
3608
|
+
getConsumerQueryMetrics(params: CBConsumerQueryMetricsParams): Promise<CBConsumerQueryMetricsResponse>;
|
|
3609
|
+
/**
|
|
3610
|
+
* Get consumer query metrics for extended date ranges (up to 3 months)
|
|
3611
|
+
*
|
|
3612
|
+
* Automatically iterates through 7-day chunks to retrieve all metrics within
|
|
3613
|
+
* the specified date range. Useful for historical analysis beyond the 7-day API limit.
|
|
3614
|
+
*
|
|
3615
|
+
* @param params - Extended query parameters including startDate, endDate, kbId, and eventType
|
|
3616
|
+
* @returns Promise resolving to aggregated consumer query metrics from all chunks
|
|
3617
|
+
*
|
|
3618
|
+
* @example
|
|
3619
|
+
* ```typescript
|
|
3620
|
+
* const metrics = await sdk.conversationBuilder.knowledgeBases.getConsumerQueryMetricsExtended({
|
|
3621
|
+
* kbId: 'kb-123',
|
|
3622
|
+
* startDate: new Date('2024-01-01'),
|
|
3623
|
+
* endDate: new Date('2024-03-01'),
|
|
3624
|
+
* eventType: ['EVENT_KB_ANSWERED', 'EVENT_KB_UN_ANSWERED'],
|
|
3625
|
+
* onProgress: (completed, total) => console.log(`${completed}/${total} chunks processed`),
|
|
3626
|
+
* });
|
|
3627
|
+
* ```
|
|
3628
|
+
*/
|
|
3629
|
+
getConsumerQueryMetricsExtended(params: CBConsumerQueryMetricsExtendedParams): Promise<CBConsumerQueryMetric[]>;
|
|
3523
3630
|
}
|
|
3524
3631
|
/**
|
|
3525
3632
|
* Bot Agents API
|
|
@@ -3999,4 +4106,4 @@ type Scope = (typeof Scopes)[keyof typeof Scopes];
|
|
|
3999
4106
|
*/
|
|
4000
4107
|
declare function getShellToken(config: ShellTokenConfig): Promise<ShellTokenResponse>;
|
|
4001
4108
|
|
|
4002
|
-
export { type CreateConversationRequest$1 as AICreateConversationRequest, AIStudioAPI, type AIStudioCategory, type AIStudioConversation, type AIStudioFlow, type AIStudioMessage, type AIStudioSimulation, type AIStudioSummary, type AIStudioUser, AIStudioUsersAPI, type UpdateConversationRequest as AIUpdateConversationRequest, type APIResponse, type ActivityRecord, type AgentActivity, AgentActivityAPI, type AgentActivityQuery, AgentGroupsAPI, type AgentMetrics, AgentMetricsAPI, type AgentMetricsQuery, type AgentParticipant, type AgentStatus, type ApiKeyAuthResponse, AutomaticMessagesAPI, type BatchSummaryRequest, BotAgentsAPI, BotGroupsAPI, BotsAPI, type CBAddBotAgentRequest, type CBAllBotAgentsStatusQueryParams, type CBApiResponse, type CBAuthCredentials, type CBAuthInfo, type CBBot, type CBBotEnvironment, type CBBotGroup, type CBBotGroupsQueryParams, type CBBotInstanceStatus, type CBBotPlatform, type CBBotUser, type CBBotsByGroupQueryParams, type CBChatBot, type CBChatBotMetrics, type CBChatBotPlatformUser, type CBChatBotSummary, type CBChatBotSummaryList, type CBCredential, type CBDialog, type CBDialogGroup, type CBDialogTemplateSummary, type CBDomainList, type CBDuplicatePhrase, type CBDuplicatePhrases, type CBGlobalFunctions, type CBIntent, type CBInteraction, type CBInteractionContent, type CBInteractionList, type CBKAIOnDemandConfig, type CBKAISearchRequest, type CBKAISearchResponse, type CBKAISearchResultItem, type CBKBArticle, type CBKBArticlesQueryParams, type CBKBContentSource, type CBKBLandingPageMetrics, type CBKnowledgeBase, type CBKnowledgeBaseDetail, type CBKnowledgeBaseList, type CBLPAppCredentials, type CBLPSkill, type CBNLUDomain, type CBPCSBotsStatusQueryParams, type CBPageContext, type CBPaginatedResult, type CBResponder, type CBResponseMatch, type CBSuccessResult, type CBSyncStatusDetails, type CBTileData, CampaignsAPI, CategoriesAPI, type CloseConversationRequest, type CoBrowseSession, ConnectToMessagingAPI, type ConsumerParticipant, type ConsumerProfile, type ContentToRetrieve, ConversationBuilderAPI, type ConversationContext, type ConversationInteraction, type ConversationParticipant, type ConversationQueryParams, type ConversationSummary, type ConversationTransfer, ConversationsAPI, type CreateAIStudioUserRequest, type CreateAgentGroupRequest, type CreateAutomaticMessageRequest, type CreateCampaignRequest, type CreateCategoryRequest, type CreateConversationResponse, type CreateEngagementRequest, type CreateLOBRequest, type CreateLPPromptRequest, type CreatePredefinedContentRequest, type CreateProfileRequest, type CreatePromptRequest, type CreateSimulationRequest, type CreateSkillRequest, type CreateSpecialOccasionRequest, type CreateTranscriptAnalysisRequest, type CreateUserRequest, type CreateWorkingHoursRequest, DialogsAPI, EngagementsAPI, type ErrorCode, ErrorCodes, EvaluatorsAPI, type FileMessage, FlowsAPI, type GeneratedQuestion, type GeneratedRoute, GeneratorsAPI, type GuidedRoute, type GuidedRoutingEvaluationRequest, type GuidedRoutingEvaluationResponse, IntegrationsAPI, InteractionsAPI, type InvokeFlowRequest, type InvokeFlowResponse, type KAIRouteGenerationStatus, type KAIRouteGeneratorRequest, type KAIRouteGeneratorResponse, KnowledgeBasesAPI, type Knowledgebase, type KnowledgebaseHealth, type KnowledgebaseItem, type KnowledgebaseSearchRequest, type KnowledgebaseSearchResult, type KnowledgebaseTextItem, KnowledgebasesAPI, type LLMModel, type LLMProvider, LOBsAPI, type LPAgentGroup, type LPAutomaticMessage, type LPAutomaticMessageData, type LPCampaign, type LPEngagement, LPExtendSDK, type LPExtendSDKConfig, LPExtendSDKError, type LPLLMProviderModels, type LPLLMProviderSubscription, type LPLLMType, type LPLOB, type LPPermission, type LPPredefinedContent, type LPPredefinedContentData, type LPProfile, type LPPrompt, type LPPromptClientConfig, type LPPromptClientType, type LPPromptConfiguration, type LPPromptGenericConfig, type LPPromptStatus, type LPPromptVariable, type LPPromptVariableSourceType, type LPPromptVersionDetail, LPPromptsAPI, type LPPromptsQueryParams, type LPShift, type LPSkill, type LPSkillRoutingConfig, type LPSpecialOccasion, type LPSpecialOccasionEvent, type LPUser, type LPWorkingDay, type LPWorkingHours, type MemberOf, type MessageData, type MessageRecord, MessagingAPI, type MessagingConversation, type CreateConversationRequest as MessagingCreateConversationRequest, MessagingHistoryAPI, type MessagingHistoryQuery, type MessagingHistoryResponse, type MessagingInteraction, MessagingOperationsAPI, NLUDomainsAPI, type OutboundCampaignReport, type OutboundReportQuery, OutboundReportingAPI, type PaginatedResponse, PredefinedContentAPI, ProfilesAPI, type Prompt, PromptLibraryAPI, type PromptVariable, QueryAPI, type QueryGenerateRequest, type QueryGenerateResponse, type QuestionGeneratorRequest, type QuestionGeneratorResponse, type ResolutionEvaluationRequest, type ResolutionEvaluationResponse, type RichContentMessage, type SDEEvent, type SDERecord, type SDKInitResult, type Scope, Scopes, type SendMessageRequest, SentinelAPI, type SentinelAppSetting, type SentinelAppSettings, type SentinelAppUser, type SentinelAuthRequest, type SentinelCCUser, type SentinelDomainsResponse, type SentinelLoginUrlResponse, type SentinelLpToken, type SentinelLpUser, type SentinelManagerOf, type SentinelMemberOf, type SentinelProfile, type SentinelToken, type SentinelTokenExchange, type SentinelUserData, type SentinelUserSkill, type ShellTokenConfig, type ShellTokenResponse, type ShellTokenUser, type SimilarityEvaluationRequest, type SimilarityEvaluationResponse, type SimulationConfig, type SimulationJobResult, type SimulationQueryParams, type SimulationResults, type SimulationTestCase, SimulationsAPI, SkillsAPI, SpecialOccasionsAPI, SummaryAPI, type SummaryRequest, type SurveyRecord, type TextMessage, type TranscriptAnalysis, TranscriptAnalysisAPI, type TranscriptConversation, type TranscriptQuestion, type TransferConversationRequest, type UpdateAIStudioUserModelsRequest, type UpdateAIStudioUserRequest, type UpdateAgentGroupRequest, type UpdateAutomaticMessageRequest, type UpdateCampaignRequest, type UpdateCategoryRequest, type UpdateConversationAttributesRequest, type UpdateEngagementRequest, type UpdateLOBRequest, type UpdateLPPromptRequest, type UpdatePredefinedContentRequest, type UpdateProfileRequest, type UpdatePromptRequest, type UpdateSimulationRequest, type UpdateSkillRequest, type UpdateSpecialOccasionRequest, type UpdateTranscriptAnalysisRequest, type UpdateUserRequest, type UpdateWorkingHoursRequest, UsersAPI, VERSION, WorkingHoursAPI, createSDK, createSDKFromEnv, getShellToken, initializeSDK };
|
|
4109
|
+
export { type CreateConversationRequest$1 as AICreateConversationRequest, AIStudioAPI, type AIStudioCategory, type AIStudioConversation, type AIStudioFlow, type AIStudioMessage, type AIStudioSimulation, type AIStudioSummary, type AIStudioUser, AIStudioUsersAPI, type UpdateConversationRequest as AIUpdateConversationRequest, type APIResponse, type ActivityRecord, type AgentActivity, AgentActivityAPI, type AgentActivityQuery, AgentGroupsAPI, type AgentMetrics, AgentMetricsAPI, type AgentMetricsQuery, type AgentParticipant, type AgentStatus, type ApiKeyAuthResponse, AutomaticMessagesAPI, type BatchSummaryRequest, BotAgentsAPI, BotGroupsAPI, BotsAPI, type CBAddBotAgentRequest, type CBAllBotAgentsStatusQueryParams, type CBApiResponse, type CBAuthCredentials, type CBAuthInfo, type CBBot, type CBBotEnvironment, type CBBotGroup, type CBBotGroupsQueryParams, type CBBotInstanceStatus, type CBBotPlatform, type CBBotUser, type CBBotsByGroupQueryParams, type CBChatBot, type CBChatBotMetrics, type CBChatBotPlatformUser, type CBChatBotSummary, type CBChatBotSummaryList, type CBConsumerQueryEventType, type CBConsumerQueryMetric, type CBConsumerQueryMetricsExtendedParams, type CBConsumerQueryMetricsParams, type CBConsumerQueryMetricsResponse, type CBCredential, type CBDialog, type CBDialogGroup, type CBDialogTemplateSummary, type CBDomainList, type CBDuplicatePhrase, type CBDuplicatePhrases, type CBGlobalFunctions, type CBIntent, type CBInteraction, type CBInteractionContent, type CBInteractionList, type CBKAIOnDemandConfig, type CBKAISearchRequest, type CBKAISearchResponse, type CBKAISearchResultItem, type CBKBArticle, type CBKBArticlesQueryParams, type CBKBContentSource, type CBKBLandingPageMetrics, type CBKnowledgeBase, type CBKnowledgeBaseDetail, type CBKnowledgeBaseList, type CBLPAppCredentials, type CBLPSkill, type CBNLUDomain, type CBPCSBotsStatusQueryParams, type CBPageContext, type CBPaginatedResult, type CBResponder, type CBResponseMatch, type CBSuccessResult, type CBSyncStatusDetails, type CBTileData, CampaignsAPI, CategoriesAPI, type CloseConversationRequest, type CoBrowseSession, ConnectToMessagingAPI, type ConsumerParticipant, type ConsumerProfile, type ContentToRetrieve, ConversationBuilderAPI, type ConversationContext, type ConversationInteraction, type ConversationParticipant, type ConversationQueryParams, type ConversationSummary, type ConversationTransfer, ConversationsAPI, type CreateAIStudioUserRequest, type CreateAgentGroupRequest, type CreateAutomaticMessageRequest, type CreateCampaignRequest, type CreateCategoryRequest, type CreateConversationResponse, type CreateEngagementRequest, type CreateLOBRequest, type CreateLPPromptRequest, type CreatePredefinedContentRequest, type CreateProfileRequest, type CreatePromptRequest, type CreateSimulationRequest, type CreateSkillRequest, type CreateSpecialOccasionRequest, type CreateTranscriptAnalysisRequest, type CreateUserRequest, type CreateWorkingHoursRequest, DialogsAPI, EngagementsAPI, type ErrorCode, ErrorCodes, EvaluatorsAPI, type FileMessage, FlowsAPI, type GeneratedQuestion, type GeneratedRoute, GeneratorsAPI, type GuidedRoute, type GuidedRoutingEvaluationRequest, type GuidedRoutingEvaluationResponse, IntegrationsAPI, InteractionsAPI, type InvokeFlowRequest, type InvokeFlowResponse, type KAIRouteGenerationStatus, type KAIRouteGeneratorRequest, type KAIRouteGeneratorResponse, KnowledgeBasesAPI, type Knowledgebase, type KnowledgebaseHealth, type KnowledgebaseItem, type KnowledgebaseSearchRequest, type KnowledgebaseSearchResult, type KnowledgebaseTextItem, KnowledgebasesAPI, type LLMModel, type LLMProvider, LOBsAPI, type LPAgentGroup, type LPAutomaticMessage, type LPAutomaticMessageData, type LPCampaign, type LPEngagement, LPExtendSDK, type LPExtendSDKConfig, LPExtendSDKError, type LPLLMProviderModels, type LPLLMProviderSubscription, type LPLLMType, type LPLOB, type LPPermission, type LPPredefinedContent, type LPPredefinedContentData, type LPProfile, type LPPrompt, type LPPromptClientConfig, type LPPromptClientType, type LPPromptConfiguration, type LPPromptGenericConfig, type LPPromptStatus, type LPPromptVariable, type LPPromptVariableSourceType, type LPPromptVersionDetail, LPPromptsAPI, type LPPromptsQueryParams, type LPShift, type LPSkill, type LPSkillRoutingConfig, type LPSpecialOccasion, type LPSpecialOccasionEvent, type LPUser, type LPWorkingDay, type LPWorkingHours, type MemberOf, type MessageData, type MessageRecord, MessagingAPI, type MessagingConversation, type CreateConversationRequest as MessagingCreateConversationRequest, MessagingHistoryAPI, type MessagingHistoryQuery, type MessagingHistoryResponse, type MessagingInteraction, MessagingOperationsAPI, NLUDomainsAPI, type OutboundCampaignReport, type OutboundReportQuery, OutboundReportingAPI, type PaginatedResponse, PredefinedContentAPI, ProfilesAPI, type Prompt, PromptLibraryAPI, type PromptVariable, QueryAPI, type QueryGenerateRequest, type QueryGenerateResponse, type QuestionGeneratorRequest, type QuestionGeneratorResponse, type ResolutionEvaluationRequest, type ResolutionEvaluationResponse, type RichContentMessage, type SDEEvent, type SDERecord, type SDKInitResult, type Scope, Scopes, type SendMessageRequest, SentinelAPI, type SentinelAppSetting, type SentinelAppSettings, type SentinelAppUser, type SentinelAuthRequest, type SentinelCCUser, type SentinelDomainsResponse, type SentinelLoginUrlResponse, type SentinelLpToken, type SentinelLpUser, type SentinelManagerOf, type SentinelMemberOf, type SentinelProfile, type SentinelToken, type SentinelTokenExchange, type SentinelUserData, type SentinelUserSkill, type ShellTokenConfig, type ShellTokenResponse, type ShellTokenUser, type SimilarityEvaluationRequest, type SimilarityEvaluationResponse, type SimulationConfig, type SimulationJobResult, type SimulationQueryParams, type SimulationResults, type SimulationTestCase, SimulationsAPI, SkillsAPI, SpecialOccasionsAPI, SummaryAPI, type SummaryRequest, type SurveyRecord, type TextMessage, type TranscriptAnalysis, TranscriptAnalysisAPI, type TranscriptConversation, type TranscriptQuestion, type TransferConversationRequest, type UpdateAIStudioUserModelsRequest, type UpdateAIStudioUserRequest, type UpdateAgentGroupRequest, type UpdateAutomaticMessageRequest, type UpdateCampaignRequest, type UpdateCategoryRequest, type UpdateConversationAttributesRequest, type UpdateEngagementRequest, type UpdateLOBRequest, type UpdateLPPromptRequest, type UpdatePredefinedContentRequest, type UpdateProfileRequest, type UpdatePromptRequest, type UpdateSimulationRequest, type UpdateSkillRequest, type UpdateSpecialOccasionRequest, type UpdateTranscriptAnalysisRequest, type UpdateUserRequest, type UpdateWorkingHoursRequest, UsersAPI, VERSION, WorkingHoursAPI, createSDK, createSDKFromEnv, getShellToken, initializeSDK };
|
package/dist/index.js
CHANGED
|
@@ -2050,6 +2050,105 @@ var KnowledgeBasesAPI = class {
|
|
|
2050
2050
|
async getDefaultPrompt() {
|
|
2051
2051
|
return this.cb.request("cbKb", "/default-prompt");
|
|
2052
2052
|
}
|
|
2053
|
+
/**
|
|
2054
|
+
* Get consumer query metrics for a knowledge base
|
|
2055
|
+
*
|
|
2056
|
+
* Retrieves answered and/or unanswered query metrics within a date range.
|
|
2057
|
+
* Note: The API only supports 7-day ranges. For longer ranges, use getConsumerQueryMetricsExtended().
|
|
2058
|
+
*
|
|
2059
|
+
* @param params - Query parameters including kbId, startTime, endTime, and eventType
|
|
2060
|
+
* @returns Promise resolving to consumer query metrics
|
|
2061
|
+
*
|
|
2062
|
+
* @example
|
|
2063
|
+
* ```typescript
|
|
2064
|
+
* const metrics = await sdk.conversationBuilder.knowledgeBases.getConsumerQueryMetrics({
|
|
2065
|
+
* kbId: 'kb-123',
|
|
2066
|
+
* startTime: Date.now() - 7 * 24 * 60 * 60 * 1000, // 7 days ago
|
|
2067
|
+
* endTime: Date.now(),
|
|
2068
|
+
* eventType: ['EVENT_KB_UN_ANSWERED'],
|
|
2069
|
+
* });
|
|
2070
|
+
* ```
|
|
2071
|
+
*/
|
|
2072
|
+
async getConsumerQueryMetrics(params) {
|
|
2073
|
+
const body = {
|
|
2074
|
+
startTime: String(params.startTime),
|
|
2075
|
+
endTime: String(params.endTime),
|
|
2076
|
+
eventType: params.eventType,
|
|
2077
|
+
kbId: params.kbId
|
|
2078
|
+
};
|
|
2079
|
+
return this.cb.request("cbKb", "/kb/consumerQueryMetrics", {
|
|
2080
|
+
method: "POST",
|
|
2081
|
+
body
|
|
2082
|
+
});
|
|
2083
|
+
}
|
|
2084
|
+
/**
|
|
2085
|
+
* Get consumer query metrics for extended date ranges (up to 3 months)
|
|
2086
|
+
*
|
|
2087
|
+
* Automatically iterates through 7-day chunks to retrieve all metrics within
|
|
2088
|
+
* the specified date range. Useful for historical analysis beyond the 7-day API limit.
|
|
2089
|
+
*
|
|
2090
|
+
* @param params - Extended query parameters including startDate, endDate, kbId, and eventType
|
|
2091
|
+
* @returns Promise resolving to aggregated consumer query metrics from all chunks
|
|
2092
|
+
*
|
|
2093
|
+
* @example
|
|
2094
|
+
* ```typescript
|
|
2095
|
+
* const metrics = await sdk.conversationBuilder.knowledgeBases.getConsumerQueryMetricsExtended({
|
|
2096
|
+
* kbId: 'kb-123',
|
|
2097
|
+
* startDate: new Date('2024-01-01'),
|
|
2098
|
+
* endDate: new Date('2024-03-01'),
|
|
2099
|
+
* eventType: ['EVENT_KB_ANSWERED', 'EVENT_KB_UN_ANSWERED'],
|
|
2100
|
+
* onProgress: (completed, total) => console.log(`${completed}/${total} chunks processed`),
|
|
2101
|
+
* });
|
|
2102
|
+
* ```
|
|
2103
|
+
*/
|
|
2104
|
+
async getConsumerQueryMetricsExtended(params) {
|
|
2105
|
+
const { startDate, endDate, eventType, kbId, onProgress } = params;
|
|
2106
|
+
const startMs = typeof startDate === "number" ? startDate : startDate.getTime();
|
|
2107
|
+
const endMs = typeof endDate === "number" ? endDate : endDate.getTime();
|
|
2108
|
+
const maxRangeMs = 90 * 24 * 60 * 60 * 1e3;
|
|
2109
|
+
if (endMs - startMs > maxRangeMs) {
|
|
2110
|
+
throw new LPExtendSDKError(
|
|
2111
|
+
"Date range exceeds maximum of 90 days. Please use a smaller range.",
|
|
2112
|
+
ErrorCodes.INVALID_CONFIG
|
|
2113
|
+
);
|
|
2114
|
+
}
|
|
2115
|
+
const chunkSizeMs = 7 * 24 * 60 * 60 * 1e3;
|
|
2116
|
+
const chunks = [];
|
|
2117
|
+
let chunkStart = startMs;
|
|
2118
|
+
while (chunkStart < endMs) {
|
|
2119
|
+
const chunkEnd = Math.min(chunkStart + chunkSizeMs, endMs);
|
|
2120
|
+
chunks.push({ start: chunkStart, end: chunkEnd });
|
|
2121
|
+
chunkStart = chunkEnd;
|
|
2122
|
+
}
|
|
2123
|
+
const allMetrics = [];
|
|
2124
|
+
for (let i = 0; i < chunks.length; i++) {
|
|
2125
|
+
const chunk = chunks[i];
|
|
2126
|
+
try {
|
|
2127
|
+
const response = await this.getConsumerQueryMetrics({
|
|
2128
|
+
kbId,
|
|
2129
|
+
startTime: chunk.start,
|
|
2130
|
+
endTime: chunk.end,
|
|
2131
|
+
eventType
|
|
2132
|
+
});
|
|
2133
|
+
if (response.data && Array.isArray(response.data)) {
|
|
2134
|
+
allMetrics.push(...response.data);
|
|
2135
|
+
}
|
|
2136
|
+
} catch (error) {
|
|
2137
|
+
console.warn(`Failed to fetch metrics for chunk ${i + 1}/${chunks.length}:`, error);
|
|
2138
|
+
}
|
|
2139
|
+
if (onProgress) {
|
|
2140
|
+
onProgress(i + 1, chunks.length);
|
|
2141
|
+
}
|
|
2142
|
+
}
|
|
2143
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2144
|
+
const uniqueMetrics = allMetrics.filter((metric) => {
|
|
2145
|
+
const key = metric.id || `${metric.consumerQuery}-${metric.timestamp}`;
|
|
2146
|
+
if (seen.has(key)) return false;
|
|
2147
|
+
seen.add(key);
|
|
2148
|
+
return true;
|
|
2149
|
+
});
|
|
2150
|
+
return uniqueMetrics;
|
|
2151
|
+
}
|
|
2053
2152
|
};
|
|
2054
2153
|
var BotAgentsAPI = class {
|
|
2055
2154
|
constructor(cb) {
|