@oneuptime/common 13.0.7 → 13.0.8
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/Models/DatabaseModels/OnCallDutyPolicyScheduleCalendarFeed.ts +1 -1
- package/Models/DatabaseModels/ProjectOnCallCalendarFeed.ts +1 -1
- package/Models/DatabaseModels/UserOnCallCalendarFeed.ts +1 -1
- package/Server/API/AIBillingAPI.ts +1 -0
- package/Server/API/AIInsightAPI.ts +1 -4
- package/Server/API/AIInvestigationAPI.ts +1 -4
- package/Server/API/AIReadinessAPI.ts +4 -5
- package/Server/API/AlertAPI.ts +1 -0
- package/Server/API/AutoRemediationAPI.ts +1 -4
- package/Server/API/BaseAPI.ts +13 -0
- package/Server/API/BaseAnalyticsAPI.ts +80 -9
- package/Server/API/BillingAPI.ts +2 -0
- package/Server/API/BillingInvoiceAPI.ts +1 -0
- package/Server/API/BillingPaymentMethodAPI.ts +2 -0
- package/Server/API/CodeFixRunAPI.ts +1 -3
- package/Server/API/CommonAPI.ts +68 -4
- package/Server/API/DashboardAPI.ts +12 -12
- package/Server/API/GlobalConfigAPI.ts +17 -0
- package/Server/API/IncidentAPI.ts +2 -0
- package/Server/API/IncidentEpisodeAPI.ts +1 -0
- package/Server/API/NotificationAPI.ts +1 -0
- package/Server/API/OnCallCalendarAPI.ts +4 -5
- package/Server/API/OnCallDutyPolicyAPI.ts +7 -0
- package/Server/API/OnCallReadinessAPI.ts +4 -1
- package/Server/API/OnCallScheduleTimelineAPI.ts +731 -0
- package/Server/API/ProjectAPI.ts +1 -0
- package/Server/API/ScheduledMaintenanceAPI.ts +1 -0
- package/Server/API/StatusPageAPI.ts +161 -32
- package/Server/API/TeamMemberAPI.ts +3 -0
- package/Server/API/UserCallAPI.ts +2 -0
- package/Server/API/UserEmailAPI.ts +2 -0
- package/Server/API/UserIncomingCallNumberAPI.ts +2 -0
- package/Server/API/UserMicrosoftTeamsAPI.ts +1 -0
- package/Server/API/UserSlackAPI.ts +1 -0
- package/Server/API/UserSmsAPI.ts +2 -0
- package/Server/API/UserTotpAuthAPI.ts +1 -0
- package/Server/API/UserWebAuthnAPI.ts +2 -0
- package/Server/API/UserWebhookAPI.ts +1 -0
- package/Server/API/UserWhatsAppAPI.ts +2 -0
- package/Server/Middleware/MasterAdminAuthorization.ts +13 -2
- package/Server/Middleware/UserAuthorization.ts +79 -5
- package/Server/Services/ApiKeyPermissionService.ts +101 -4
- package/Server/Services/DatabaseService.ts +245 -0
- package/Server/Services/DetectionRuleService.ts +5 -4
- package/Server/Services/OnCallDutyPolicyChildService.ts +261 -0
- package/Server/Services/OnCallDutyPolicyEscalationRuleScheduleService.ts +2 -2
- package/Server/Services/OnCallDutyPolicyEscalationRuleService.ts +2 -2
- package/Server/Services/OnCallDutyPolicyEscalationRuleTeamService.ts +2 -2
- package/Server/Services/OnCallDutyPolicyEscalationRuleUserService.ts +2 -2
- package/Server/Services/PayAsYouGoBillingService.ts +23 -28
- package/Server/Services/ProjectService.ts +18 -0
- package/Server/Services/RumSessionPinService.ts +274 -22
- package/Server/Services/TeamPermissionService.ts +120 -26
- package/Server/Services/ThreatIntelFeedService.ts +6 -3
- package/Server/Types/Database/Permissions/BasePermission.ts +9 -7
- package/Server/Types/Database/Permissions/Index.ts +75 -11
- package/Server/Types/Database/Permissions/TablePermission.ts +24 -28
- package/Server/Utils/AI/AIChatPrivacyFilter.ts +8 -0
- package/Server/Utils/AI/AIRunPrivacyFilter.ts +8 -0
- package/Server/Utils/MasterAdminPageAccess.ts +61 -0
- package/Server/Utils/Monitor/MonitorAlert.ts +3 -1
- package/Server/Utils/Monitor/MonitorIncident.ts +3 -1
- package/Server/Utils/OnCall/OnCallCalendarFeedRenderer.ts +1 -1
- package/Server/Utils/Realtime.ts +163 -45
- package/Server/Utils/SecurityEvent/DetectionRuleEvaluator.ts +11 -28
- package/Server/Utils/SecurityEvent/GoogleSecOpsSeverityRepair.ts +170 -0
- package/Server/Utils/SecurityEvent/Sigma/SigmaClickhouseCompiler.ts +1 -1
- package/Server/Utils/SecurityEvent/ThreatIntel/ThreatIntelFeedPoller.ts +6 -2
- package/Server/Utils/SecurityEvent/ThreatIntel/ThreatIntelMatcher.ts +10 -9
- package/Tests/App/Dashboard/AffectedResourcesPicker.test.tsx +1059 -0
- package/Tests/App/Dashboard/AffectedResourcesPickerEditForm.test.tsx +376 -0
- package/Tests/App/Dashboard/AffectedResourcesPickerHiddenTypes.test.tsx +757 -0
- package/Tests/App/Dashboard/AffectedResourcesSummaryStep.test.tsx +307 -0
- package/Tests/App/Dashboard/ArgumentsFormGroupByUnlistedAttributes.test.tsx +131 -0
- package/Tests/App/Dashboard/DashboardHeaderRequests.test.tsx +1 -1
- package/Tests/App/Dashboard/DashboardMonitorLabelVariable.test.tsx +9 -1
- package/Tests/App/Dashboard/DashboardVariableAllContract.test.tsx +24 -0
- package/Tests/App/Dashboard/DashboardVariableSelector.test.tsx +162 -8
- package/Tests/App/Dashboard/EntityFilterDropdownArchivedSlos.test.tsx +105 -6
- package/Tests/App/Dashboard/EntityFilterDropdownUnlistedSelection.test.tsx +434 -0
- package/Tests/App/Dashboard/EscalationRuleReadiness.test.tsx +276 -1
- package/Tests/App/Dashboard/OnCallCalendarFeedSideMenus.test.tsx +9 -1
- package/Tests/App/Dashboard/PayAsYouGoConsentGate.test.tsx +58 -42
- package/Tests/App/Dashboard/PayAsYouGoNotices.test.tsx +42 -5
- package/Tests/App/Dashboard/ResourceAuditLogsSideMenus.test.tsx +34 -23
- package/Tests/App/Dashboard/ScheduleTimeline.test.tsx +1580 -0
- package/Tests/App/Dashboard/ScheduleTimelineAPI.test.ts +280 -0
- package/Tests/App/Dashboard/ScheduleTimelineModel.test.ts +673 -0
- package/Tests/App/Dashboard/SecurityEventConnectionDiagnostics.test.tsx +95 -68
- package/Tests/App/Dashboard/SecurityEventsDetectionRulesPage.test.tsx +86 -3
- package/Tests/App/Dashboard/SecurityEventsEmptyState.test.tsx +28 -3
- package/Tests/App/Dashboard/SecurityEventsExplorer.test.tsx +761 -0
- package/Tests/App/Dashboard/SecurityEventsGuideContent.test.ts +1313 -0
- package/Tests/App/Dashboard/SecurityEventsHowItWorksCard.test.tsx +536 -0
- package/Tests/App/Dashboard/SecurityEventsNoResults.test.tsx +222 -0
- package/Tests/App/Dashboard/SecurityEventsThreatIntelPage.test.tsx +199 -0
- package/Tests/App/Dashboard/SecurityEventsVolumeChart.test.tsx +321 -0
- package/Tests/App/Dashboard/SloOverviewHero.test.tsx +171 -36
- package/Tests/App/Dashboard/SloViewSideMenu.test.tsx +215 -0
- package/Tests/App/Dashboard/SloViewSideMenuCounts.test.tsx +40 -3
- package/Tests/App/PublicDashboard/DashboardVariableSelector.test.tsx +12 -4
- package/Tests/App/PublicDashboard/PublicDashboardWidgetListAuth.test.tsx +623 -0
- package/Tests/Models/OnCallCalendarFeedModels.test.ts +23 -1
- package/Tests/Server/API/AIChatRouteAuthorization.test.ts +138 -5
- package/Tests/Server/API/AIGenerationProjectAIToggle.test.ts +187 -0
- package/Tests/Server/API/AIInvestigationAvailabilityAuthorization.test.ts +51 -3
- package/Tests/Server/API/AIInvestigationEvidenceAPI.test.ts +55 -2
- package/Tests/Server/API/BaseAnalyticsAPIAggregateCache.test.ts +729 -0
- package/Tests/Server/API/BillingPayAsYouGoStatus.test.ts +93 -7
- package/Tests/Server/API/BillingPaymentMethodAPI.test.ts +36 -3
- package/Tests/Server/API/CommonAPIAuthGuard.test.ts +1003 -24
- package/Tests/Server/API/DashboardPublicRateLimit.test.ts +6 -3
- package/Tests/Server/API/ExpiredSessionAIRoutes.test.ts +708 -0
- package/Tests/Server/API/ExpiredSessionCustomRoutes.test.ts +928 -0
- package/Tests/Server/API/ExpiredSessionMonitorTemplate.test.ts +319 -0
- package/Tests/Server/API/ExpiredSessionOnCallDutyPolicy.test.ts +336 -0
- package/Tests/Server/API/ExpiredSessionRouteGuards.test.ts +820 -0
- package/Tests/Server/API/GlobalConfigLicense.test.ts +140 -0
- package/Tests/Server/API/NotificationChannelVerificationAPI.test.ts +115 -12
- package/Tests/Server/API/OnCallCalendarAPI.test.ts +375 -8
- package/Tests/Server/API/OnCallReadinessAPI.test.ts +175 -17
- package/Tests/Server/API/OnCallScheduleTimelineAPI.test.ts +1513 -0
- package/Tests/Server/API/OnCallSetupReminderAPI.test.ts +119 -7
- package/Tests/Server/API/ProjectScopedCustomRouteAuth.test.ts +111 -4
- package/Tests/Server/API/PublicRouteInvalidAccessToken.test.ts +615 -0
- package/Tests/Server/API/SecurityEventAttributesAPI.test.ts +89 -2
- package/Tests/Server/API/SessionReplayAPI.test.ts +121 -0
- package/Tests/Server/API/StatusPageMasterPasswordRateLimit.test.ts +4 -2
- package/Tests/Server/API/StatusPagePostmortemVisibility.test.ts +441 -0
- package/Tests/Server/API/StatusPageTestEmailReportAuth.test.ts +664 -0
- package/Tests/Server/API/TeamMemberRemoveUserFromProjectAPI.test.ts +7 -0
- package/Tests/Server/API/UserIncomingCallNumberApi.test.ts +6 -0
- package/Tests/Server/API/UserNotificationSettingAPI.test.ts +65 -4
- package/Tests/Server/API/UserProjectsAPI.test.ts +63 -3
- package/Tests/Server/API/UserTotpAuthAPI.test.ts +48 -2
- package/Tests/Server/API/UserWebAuthnAuthenticationOptionsRoute.test.ts +11 -2
- package/Tests/Server/API/UserWebAuthnBackupCodeMinting.test.ts +46 -3
- package/Tests/Server/API/UserWebAuthnPasskeyAPI.test.ts +18 -2
- package/Tests/Server/API/ZZVerifyChatsAuth.test.ts +24 -7
- package/Tests/Server/Middleware/ExpiredSessionUserMiddleware.test.ts +563 -0
- package/Tests/Server/Middleware/MasterAdminAuthorization.test.ts +299 -19
- package/Tests/Server/Middleware/PublicRouteUserMiddleware.test.ts +453 -0
- package/Tests/Server/Services/AIChatPrivacyPin.test.ts +24 -0
- package/Tests/Server/Services/ApiKeyPermissionSecurity.test.ts +2 -0
- package/Tests/Server/Services/ApiKeyPermissionService.test.ts +3 -3
- package/Tests/Server/Services/DatabaseServiceCreateSuppliedId.test.ts +147 -0
- package/Tests/Server/Services/DatabaseServiceLoginBeforeHooks.test.ts +1078 -0
- package/Tests/Server/Services/DatabaseServiceTenantRelationGuard.test.ts +259 -0
- package/Tests/Server/Services/DatabaseServiceWriteOperatorValues.test.ts +147 -0
- package/Tests/Server/Services/MonitorPayAsYouGoBilling.test.ts +115 -1
- package/Tests/Server/Services/OnCallChildCreateAuthorizationPostgres.test.ts +711 -0
- package/Tests/Server/Services/OnCallDutyPolicyChildService.test.ts +733 -0
- package/Tests/Server/Services/PayAsYouGoBillingService.test.ts +190 -140
- package/Tests/Server/Services/PayAsYouGoStripeRateLimitBudget.test.ts +4 -9
- package/Tests/Server/Services/PermissionBlockDeletion.test.ts +780 -0
- package/Tests/Server/Services/PermissionBlockDeletionPostgres.test.ts +628 -0
- package/Tests/Server/Services/ProjectServiceCreateSubscriptionStarted.test.ts +77 -1
- package/Tests/Server/Services/RumSessionPinCreatePermission.test.ts +715 -0
- package/Tests/Server/Services/TeamMemberMultiTenantReadPostgres.test.ts +394 -0
- package/Tests/Server/Services/TeamPrivilegeEscalation.test.ts +6 -0
- package/Tests/Server/Services/TelemetryPayAsYouGoBilling.test.ts +131 -0
- package/Tests/Server/Services/UserNotificationRuleAdminGuards.test.ts +13 -2
- package/Tests/Server/Types/Database/Permissions/ModelPermissionAnonymousRefusal.test.ts +518 -0
- package/Tests/Server/Types/Database/Permissions/MultiTenantPermissions.test.ts +350 -0
- package/Tests/Server/Types/Database/Permissions/OnCallCalendarFeedPermissions.test.ts +282 -25
- package/Tests/Server/Types/Database/Permissions/TableLevelBlockPermission.test.ts +459 -0
- package/Tests/Server/Utils/AI/AIRunPrivacyFilter.test.ts +101 -9
- package/Tests/Server/Utils/AI/ChatAgentHelpers.test.ts +88 -4
- package/Tests/Server/Utils/AI/Toolbox/ExceptionTools.test.ts +459 -0
- package/Tests/Server/Utils/AI/Toolbox/LogTools.test.ts +794 -0
- package/Tests/Server/Utils/AI/Toolbox/RecentChangesTools.test.ts +574 -0
- package/Tests/Server/Utils/AI/Toolbox/SecurityEventTools.test.ts +596 -0
- package/Tests/Server/Utils/CaptchaRequestAndLogging.test.ts +395 -0
- package/Tests/Server/Utils/MasterAdminPageAccess.test.ts +251 -0
- package/Tests/Server/Utils/Monitor/MonitorActionTimestamps.test.ts +616 -0
- package/Tests/Server/Utils/Realtime.test.ts +502 -0
- package/Tests/Server/Utils/SecurityEvent/Connectors/GoogleSecOps/GoogleSecOpsConnectorSeverity.test.ts +216 -0
- package/Tests/Server/Utils/SecurityEvent/DetectionRuleEvaluator.test.ts +142 -0
- package/Tests/Server/Utils/SecurityEvent/GoogleSecOpsSeverityRepair.test.ts +140 -0
- package/Tests/Server/Utils/SecurityEvent/GoogleSecOpsSeverityRepairClickhouseIntegration.test.ts +542 -0
- package/Tests/Server/Utils/Telemetry/ChangeEventRow.test.ts +743 -0
- package/Tests/Server/Utils/Telemetry/RuntimeMetrics.test.ts +465 -0
- package/Tests/Server/Utils/Workspace/MicrosoftTeams/Messages/Alert.test.ts +202 -0
- package/Tests/Server/Utils/Workspace/MicrosoftTeams/Messages/Incident.test.ts +194 -0
- package/Tests/Server/Utils/Workspace/MicrosoftTeams/Messages/ScheduledMaintenance.test.ts +231 -0
- package/Tests/Server/Utils/Workspace/Slack/Messages/Alert.test.ts +194 -0
- package/Tests/Server/Utils/Workspace/Slack/Messages/AlertEpisode.test.ts +194 -0
- package/Tests/Server/Utils/Workspace/Slack/Messages/Incident.test.ts +194 -0
- package/Tests/Server/Utils/Workspace/Slack/Messages/IncidentEpisode.test.ts +194 -0
- package/Tests/Server/Utils/Workspace/Slack/Messages/ScheduledMaintenance.test.ts +247 -0
- package/Tests/Types/AI/AIInsightEvidence.test.ts +206 -0
- package/Tests/Types/BaseDatabase/DatabaseCommonInteractionPropsUtilAnonymous.test.ts +144 -0
- package/Tests/Types/Call/CallProvider.test.ts +528 -0
- package/Tests/Types/Kubernetes/KubernetesCostIngest.test.ts +236 -0
- package/Tests/Types/OnCallDutyPolicy/ScheduleTimeline.test.ts +736 -0
- package/Tests/Types/OnCallDutyPolicy/ScheduleTimelineLayout.test.ts +996 -0
- package/Tests/Types/SecurityEvent/SigmaRule.test.ts +142 -0
- package/Tests/Types/Workflow/Components/JSON.test.ts +182 -0
- package/Tests/UI/Components/BasicFormDropdownNormalization.test.tsx +116 -1
- package/Tests/UI/Components/Dropdown/DropdownAsyncOptions.test.tsx +81 -0
- package/Tests/UI/Components/EditionLabelLicenseRefresh.test.tsx +89 -1
- package/Tests/UI/Components/EventAttachmentList.test.tsx +174 -0
- package/Tests/UI/Components/Forms/BasicFormBurnRateTemplateDefaults.test.tsx +395 -0
- package/Tests/UI/Components/Forms/BasicFormCollapsibleSections.test.tsx +286 -0
- package/Tests/UI/Components/Forms/FormSummary.test.tsx +128 -0
- package/Tests/UI/Components/ModelTable/BaseModelTableQueryChange.test.tsx +365 -0
- package/Tests/UI/Components/OpenAuthenticatedUrl.test.ts +358 -0
- package/Tests/UI/Components/SessionAwareImage.test.tsx +496 -0
- package/Tests/UI/Components/TelemetryHistogramZeroBuckets.test.tsx +190 -0
- package/Tests/UI/Components/TooltipInteractive.test.tsx +97 -0
- package/Tests/UI/MicrosoftTeams/MicrosoftTeamsChatsCardInstallGuidance.test.tsx +1 -1
- package/Tests/UI/Monitor/EvaluationLogListTimestamps.test.tsx +367 -0
- package/Tests/UI/Utils/API/BaseAPIRefreshSession.test.ts +1087 -0
- package/Tests/UI/Utils/API/DashboardHost.ts +12 -0
- package/Tests/UI/Utils/API/FakeAxiosServer.ts +183 -0
- package/Tests/UI/Utils/Breadcrumb/fixtures/RealBreadcrumbTrails.ts +10 -0
- package/Tests/UI/Utils/Breadcrumb/fixtures/RealRoutePatterns.ts +2 -0
- package/Tests/UI/Utils/Cookie.test.ts +440 -0
- package/Tests/UI/Utils/ModelAPIRequestClient.test.ts +278 -0
- package/Tests/UI/Utils/Navigation.test.ts +33 -0
- package/Tests/UI/Utils/PricingPlan.test.ts +295 -0
- package/Tests/UI/Utils/Realtime.test.ts +759 -0
- package/Tests/UI/Utils/Telemetry/Telemetry.test.ts +500 -0
- package/Tests/Utils/APIInstanceDispatch.test.ts +311 -0
- package/Tests/Utils/SecurityEvent/GoogleSecOpsAlertNormalizerSeverity.test.ts +565 -0
- package/Types/BaseDatabase/DatabaseCommonInteractionPropsUtil.ts +40 -0
- package/Types/Monitor/MonitorEvaluationSummary.ts +3 -0
- package/Types/OnCallDutyPolicy/ScheduleTimeline.ts +507 -0
- package/Types/OnCallDutyPolicy/ScheduleTimelineLayout.ts +589 -0
- package/Types/Realtime/EventName.ts +11 -0
- package/Types/SecurityEvent/DetectionFindingConstants.ts +14 -0
- package/Types/SecurityEvent/OcsfSeverity.ts +31 -26
- package/Types/SecurityEvent/SigmaRule.ts +51 -0
- package/Types/SecurityEvent/ThreatIntelConstants.ts +18 -0
- package/UI/Components/AttachmentList/EventAttachmentList.tsx +30 -2
- package/UI/Components/Dashboard/DashboardVariableControl.tsx +12 -2
- package/UI/Components/Dropdown/Dropdown.tsx +6 -1
- package/UI/Components/EditionLabel/EditionLabel.tsx +12 -0
- package/UI/Components/EventItem/EventItem.tsx +12 -1
- package/UI/Components/Forms/BasicForm.tsx +151 -126
- package/UI/Components/Forms/CollapsibleFormSection.tsx +63 -0
- package/UI/Components/Forms/Fields/FormField.tsx +10 -4
- package/UI/Components/Forms/FormSummary.tsx +7 -0
- package/UI/Components/Forms/Types/Field.ts +10 -0
- package/UI/Components/Markdown.tsx/MarkdownViewer.tsx +2 -1
- package/UI/Components/Markdown.tsx/SessionAwareImage.tsx +122 -0
- package/UI/Components/ModelTable/BaseModelTable.tsx +34 -5
- package/UI/Components/ModelTable/TableView.tsx +1 -1
- package/UI/Components/TelemetryViewer/components/TelemetryHistogram.tsx +8 -1
- package/UI/Components/Tooltip/Tooltip.tsx +8 -1
- package/UI/Utils/API/API.ts +173 -12
- package/UI/Utils/API/RequestOptions.ts +11 -0
- package/UI/Utils/AnalyticsModelAPI/AnalyticsModelAPI.ts +31 -7
- package/UI/Utils/ModelAPI/ModelAPI.ts +30 -9
- package/UI/Utils/Navigation.ts +9 -0
- package/UI/Utils/OpenAuthenticatedUrl.ts +154 -0
- package/UI/Utils/Realtime.ts +176 -30
- package/Utils/API.ts +14 -5
- package/Utils/SecurityEvent/GoogleSecOpsAlertNormalizer.ts +157 -7
- package/Utils/SecurityEvent/Sigma/SigmaRuleParser.ts +9 -17
- package/Utils/Slo/SloBurnRateTemplate.ts +2 -2
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyScheduleCalendarFeed.js +1 -1
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyScheduleCalendarFeed.js.map +1 -1
- package/build/dist/Models/DatabaseModels/ProjectOnCallCalendarFeed.js +1 -1
- package/build/dist/Models/DatabaseModels/ProjectOnCallCalendarFeed.js.map +1 -1
- package/build/dist/Models/DatabaseModels/UserOnCallCalendarFeed.js +1 -1
- package/build/dist/Models/DatabaseModels/UserOnCallCalendarFeed.js.map +1 -1
- package/build/dist/Server/API/AIBillingAPI.js +1 -1
- package/build/dist/Server/API/AIBillingAPI.js.map +1 -1
- package/build/dist/Server/API/AIInsightAPI.js +1 -4
- package/build/dist/Server/API/AIInsightAPI.js.map +1 -1
- package/build/dist/Server/API/AIInvestigationAPI.js +1 -4
- package/build/dist/Server/API/AIInvestigationAPI.js.map +1 -1
- package/build/dist/Server/API/AIReadinessAPI.js +1 -3
- package/build/dist/Server/API/AIReadinessAPI.js.map +1 -1
- package/build/dist/Server/API/AlertAPI.js +1 -1
- package/build/dist/Server/API/AlertAPI.js.map +1 -1
- package/build/dist/Server/API/AutoRemediationAPI.js +1 -4
- package/build/dist/Server/API/AutoRemediationAPI.js.map +1 -1
- package/build/dist/Server/API/BaseAPI.js +12 -0
- package/build/dist/Server/API/BaseAPI.js.map +1 -1
- package/build/dist/Server/API/BaseAnalyticsAPI.js +55 -10
- package/build/dist/Server/API/BaseAnalyticsAPI.js.map +1 -1
- package/build/dist/Server/API/BillingAPI.js +2 -2
- package/build/dist/Server/API/BillingAPI.js.map +1 -1
- package/build/dist/Server/API/BillingInvoiceAPI.js +1 -1
- package/build/dist/Server/API/BillingInvoiceAPI.js.map +1 -1
- package/build/dist/Server/API/BillingPaymentMethodAPI.js +2 -2
- package/build/dist/Server/API/BillingPaymentMethodAPI.js.map +1 -1
- package/build/dist/Server/API/CodeFixRunAPI.js +1 -3
- package/build/dist/Server/API/CodeFixRunAPI.js.map +1 -1
- package/build/dist/Server/API/CommonAPI.js +50 -5
- package/build/dist/Server/API/CommonAPI.js.map +1 -1
- package/build/dist/Server/API/DashboardAPI.js +12 -12
- package/build/dist/Server/API/DashboardAPI.js.map +1 -1
- package/build/dist/Server/API/GlobalConfigAPI.js +12 -0
- package/build/dist/Server/API/GlobalConfigAPI.js.map +1 -1
- package/build/dist/Server/API/IncidentAPI.js +2 -2
- package/build/dist/Server/API/IncidentAPI.js.map +1 -1
- package/build/dist/Server/API/IncidentEpisodeAPI.js +1 -1
- package/build/dist/Server/API/IncidentEpisodeAPI.js.map +1 -1
- package/build/dist/Server/API/NotificationAPI.js +1 -1
- package/build/dist/Server/API/NotificationAPI.js.map +1 -1
- package/build/dist/Server/API/OnCallCalendarAPI.js +1 -4
- package/build/dist/Server/API/OnCallCalendarAPI.js.map +1 -1
- package/build/dist/Server/API/OnCallDutyPolicyAPI.js +6 -0
- package/build/dist/Server/API/OnCallDutyPolicyAPI.js.map +1 -1
- package/build/dist/Server/API/OnCallReadinessAPI.js +4 -1
- package/build/dist/Server/API/OnCallReadinessAPI.js.map +1 -1
- package/build/dist/Server/API/OnCallScheduleTimelineAPI.js +494 -0
- package/build/dist/Server/API/OnCallScheduleTimelineAPI.js.map +1 -0
- package/build/dist/Server/API/ProjectAPI.js +1 -1
- package/build/dist/Server/API/ProjectAPI.js.map +1 -1
- package/build/dist/Server/API/ScheduledMaintenanceAPI.js +1 -1
- package/build/dist/Server/API/ScheduledMaintenanceAPI.js.map +1 -1
- package/build/dist/Server/API/StatusPageAPI.js +125 -33
- package/build/dist/Server/API/StatusPageAPI.js.map +1 -1
- package/build/dist/Server/API/TeamMemberAPI.js +3 -3
- package/build/dist/Server/API/TeamMemberAPI.js.map +1 -1
- package/build/dist/Server/API/UserCallAPI.js +2 -2
- package/build/dist/Server/API/UserCallAPI.js.map +1 -1
- package/build/dist/Server/API/UserEmailAPI.js +2 -2
- package/build/dist/Server/API/UserEmailAPI.js.map +1 -1
- package/build/dist/Server/API/UserIncomingCallNumberAPI.js +2 -2
- package/build/dist/Server/API/UserIncomingCallNumberAPI.js.map +1 -1
- package/build/dist/Server/API/UserMicrosoftTeamsAPI.js +1 -1
- package/build/dist/Server/API/UserMicrosoftTeamsAPI.js.map +1 -1
- package/build/dist/Server/API/UserSlackAPI.js +1 -1
- package/build/dist/Server/API/UserSlackAPI.js.map +1 -1
- package/build/dist/Server/API/UserSmsAPI.js +2 -2
- package/build/dist/Server/API/UserSmsAPI.js.map +1 -1
- package/build/dist/Server/API/UserTotpAuthAPI.js +1 -1
- package/build/dist/Server/API/UserTotpAuthAPI.js.map +1 -1
- package/build/dist/Server/API/UserWebAuthnAPI.js +2 -2
- package/build/dist/Server/API/UserWebAuthnAPI.js.map +1 -1
- package/build/dist/Server/API/UserWebhookAPI.js +1 -1
- package/build/dist/Server/API/UserWebhookAPI.js.map +1 -1
- package/build/dist/Server/API/UserWhatsAppAPI.js +2 -2
- package/build/dist/Server/API/UserWhatsAppAPI.js.map +1 -1
- package/build/dist/Server/Middleware/MasterAdminAuthorization.js +11 -2
- package/build/dist/Server/Middleware/MasterAdminAuthorization.js.map +1 -1
- package/build/dist/Server/Middleware/UserAuthorization.js +64 -4
- package/build/dist/Server/Middleware/UserAuthorization.js.map +1 -1
- package/build/dist/Server/Services/ApiKeyPermissionService.js +80 -4
- package/build/dist/Server/Services/ApiKeyPermissionService.js.map +1 -1
- package/build/dist/Server/Services/DatabaseService.js +171 -0
- package/build/dist/Server/Services/DatabaseService.js.map +1 -1
- package/build/dist/Server/Services/DetectionRuleService.js +4 -4
- package/build/dist/Server/Services/DetectionRuleService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyChildService.js +170 -0
- package/build/dist/Server/Services/OnCallDutyPolicyChildService.js.map +1 -0
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleScheduleService.js +2 -2
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleScheduleService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleService.js +2 -2
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleTeamService.js +2 -2
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleTeamService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleUserService.js +2 -2
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleUserService.js.map +1 -1
- package/build/dist/Server/Services/PayAsYouGoBillingService.js +20 -27
- package/build/dist/Server/Services/PayAsYouGoBillingService.js.map +1 -1
- package/build/dist/Server/Services/ProjectService.js +17 -0
- package/build/dist/Server/Services/ProjectService.js.map +1 -1
- package/build/dist/Server/Services/RumSessionPinService.js +180 -16
- package/build/dist/Server/Services/RumSessionPinService.js.map +1 -1
- package/build/dist/Server/Services/TeamPermissionService.js +89 -27
- package/build/dist/Server/Services/TeamPermissionService.js.map +1 -1
- package/build/dist/Server/Services/ThreatIntelFeedService.js +5 -4
- package/build/dist/Server/Services/ThreatIntelFeedService.js.map +1 -1
- package/build/dist/Server/Types/Database/Permissions/BasePermission.js +9 -6
- package/build/dist/Server/Types/Database/Permissions/BasePermission.js.map +1 -1
- package/build/dist/Server/Types/Database/Permissions/Index.js +60 -6
- package/build/dist/Server/Types/Database/Permissions/Index.js.map +1 -1
- package/build/dist/Server/Types/Database/Permissions/TablePermission.js +14 -13
- package/build/dist/Server/Types/Database/Permissions/TablePermission.js.map +1 -1
- package/build/dist/Server/Utils/AI/AIChatPrivacyFilter.js +7 -0
- package/build/dist/Server/Utils/AI/AIChatPrivacyFilter.js.map +1 -1
- package/build/dist/Server/Utils/AI/AIRunPrivacyFilter.js +7 -0
- package/build/dist/Server/Utils/AI/AIRunPrivacyFilter.js.map +1 -1
- package/build/dist/Server/Utils/MasterAdminPageAccess.js +39 -0
- package/build/dist/Server/Utils/MasterAdminPageAccess.js.map +1 -0
- package/build/dist/Server/Utils/Monitor/MonitorAlert.js +3 -1
- package/build/dist/Server/Utils/Monitor/MonitorAlert.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorIncident.js +3 -1
- package/build/dist/Server/Utils/Monitor/MonitorIncident.js.map +1 -1
- package/build/dist/Server/Utils/Realtime.js +126 -37
- package/build/dist/Server/Utils/Realtime.js.map +1 -1
- package/build/dist/Server/Utils/SecurityEvent/DetectionRuleEvaluator.js +7 -25
- package/build/dist/Server/Utils/SecurityEvent/DetectionRuleEvaluator.js.map +1 -1
- package/build/dist/Server/Utils/SecurityEvent/GoogleSecOpsSeverityRepair.js +127 -0
- package/build/dist/Server/Utils/SecurityEvent/GoogleSecOpsSeverityRepair.js.map +1 -0
- package/build/dist/Server/Utils/SecurityEvent/Sigma/SigmaClickhouseCompiler.js +1 -1
- package/build/dist/Server/Utils/SecurityEvent/Sigma/SigmaClickhouseCompiler.js.map +1 -1
- package/build/dist/Server/Utils/SecurityEvent/ThreatIntel/ThreatIntelFeedPoller.js +3 -2
- package/build/dist/Server/Utils/SecurityEvent/ThreatIntel/ThreatIntelFeedPoller.js.map +1 -1
- package/build/dist/Server/Utils/SecurityEvent/ThreatIntel/ThreatIntelMatcher.js +4 -8
- package/build/dist/Server/Utils/SecurityEvent/ThreatIntel/ThreatIntelMatcher.js.map +1 -1
- package/build/dist/Types/BaseDatabase/DatabaseCommonInteractionPropsUtil.js +31 -1
- package/build/dist/Types/BaseDatabase/DatabaseCommonInteractionPropsUtil.js.map +1 -1
- package/build/dist/Types/OnCallDutyPolicy/ScheduleTimeline.js +321 -0
- package/build/dist/Types/OnCallDutyPolicy/ScheduleTimeline.js.map +1 -0
- package/build/dist/Types/OnCallDutyPolicy/ScheduleTimelineLayout.js +372 -0
- package/build/dist/Types/OnCallDutyPolicy/ScheduleTimelineLayout.js.map +1 -0
- package/build/dist/Types/Realtime/EventName.js +10 -0
- package/build/dist/Types/Realtime/EventName.js.map +1 -1
- package/build/dist/Types/SecurityEvent/DetectionFindingConstants.js +11 -0
- package/build/dist/Types/SecurityEvent/DetectionFindingConstants.js.map +1 -1
- package/build/dist/Types/SecurityEvent/OcsfSeverity.js +30 -25
- package/build/dist/Types/SecurityEvent/OcsfSeverity.js.map +1 -1
- package/build/dist/Types/SecurityEvent/SigmaRule.js +47 -0
- package/build/dist/Types/SecurityEvent/SigmaRule.js.map +1 -1
- package/build/dist/Types/SecurityEvent/ThreatIntelConstants.js +14 -0
- package/build/dist/Types/SecurityEvent/ThreatIntelConstants.js.map +1 -1
- package/build/dist/UI/Components/AttachmentList/EventAttachmentList.js +9 -4
- package/build/dist/UI/Components/AttachmentList/EventAttachmentList.js.map +1 -1
- package/build/dist/UI/Components/Dashboard/DashboardVariableControl.js +10 -2
- package/build/dist/UI/Components/Dashboard/DashboardVariableControl.js.map +1 -1
- package/build/dist/UI/Components/Dropdown/Dropdown.js +5 -1
- package/build/dist/UI/Components/Dropdown/Dropdown.js.map +1 -1
- package/build/dist/UI/Components/EditionLabel/EditionLabel.js +11 -0
- package/build/dist/UI/Components/EditionLabel/EditionLabel.js.map +1 -1
- package/build/dist/UI/Components/EventItem/EventItem.js +2 -2
- package/build/dist/UI/Components/EventItem/EventItem.js.map +1 -1
- package/build/dist/UI/Components/Forms/BasicForm.js +70 -64
- package/build/dist/UI/Components/Forms/BasicForm.js.map +1 -1
- package/build/dist/UI/Components/Forms/CollapsibleFormSection.js +27 -0
- package/build/dist/UI/Components/Forms/CollapsibleFormSection.js.map +1 -0
- package/build/dist/UI/Components/Forms/Fields/FormField.js +10 -7
- package/build/dist/UI/Components/Forms/Fields/FormField.js.map +1 -1
- package/build/dist/UI/Components/Forms/FormSummary.js +7 -0
- package/build/dist/UI/Components/Forms/FormSummary.js.map +1 -1
- package/build/dist/UI/Components/Markdown.tsx/MarkdownViewer.js +2 -1
- package/build/dist/UI/Components/Markdown.tsx/MarkdownViewer.js.map +1 -1
- package/build/dist/UI/Components/Markdown.tsx/SessionAwareImage.js +84 -0
- package/build/dist/UI/Components/Markdown.tsx/SessionAwareImage.js.map +1 -0
- package/build/dist/UI/Components/ModelTable/BaseModelTable.js +14 -1
- package/build/dist/UI/Components/ModelTable/BaseModelTable.js.map +1 -1
- package/build/dist/UI/Components/ModelTable/TableView.js +1 -1
- package/build/dist/UI/Components/ModelTable/TableView.js.map +1 -1
- package/build/dist/UI/Components/TelemetryViewer/components/TelemetryHistogram.js +8 -1
- package/build/dist/UI/Components/TelemetryViewer/components/TelemetryHistogram.js.map +1 -1
- package/build/dist/UI/Components/Tooltip/Tooltip.js +2 -1
- package/build/dist/UI/Components/Tooltip/Tooltip.js.map +1 -1
- package/build/dist/UI/Utils/API/API.js +143 -19
- package/build/dist/UI/Utils/API/API.js.map +1 -1
- package/build/dist/UI/Utils/AnalyticsModelAPI/AnalyticsModelAPI.js +21 -7
- package/build/dist/UI/Utils/AnalyticsModelAPI/AnalyticsModelAPI.js.map +1 -1
- package/build/dist/UI/Utils/ModelAPI/ModelAPI.js +26 -9
- package/build/dist/UI/Utils/ModelAPI/ModelAPI.js.map +1 -1
- package/build/dist/UI/Utils/Navigation.js +8 -0
- package/build/dist/UI/Utils/Navigation.js.map +1 -1
- package/build/dist/UI/Utils/OpenAuthenticatedUrl.js +92 -0
- package/build/dist/UI/Utils/OpenAuthenticatedUrl.js.map +1 -0
- package/build/dist/UI/Utils/Realtime.js +120 -15
- package/build/dist/UI/Utils/Realtime.js.map +1 -1
- package/build/dist/Utils/API.js +13 -5
- package/build/dist/Utils/API.js.map +1 -1
- package/build/dist/Utils/SecurityEvent/GoogleSecOpsAlertNormalizer.js +123 -6
- package/build/dist/Utils/SecurityEvent/GoogleSecOpsAlertNormalizer.js.map +1 -1
- package/build/dist/Utils/SecurityEvent/Sigma/SigmaRuleParser.js +4 -18
- package/build/dist/Utils/SecurityEvent/Sigma/SigmaRuleParser.js.map +1 -1
- package/build/dist/Utils/Slo/SloBurnRateTemplate.js +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,794 @@
|
|
|
1
|
+
import Log from "../../../../../Models/AnalyticsModels/Log";
|
|
2
|
+
import LogService from "../../../../../Server/Services/LogService";
|
|
3
|
+
import LogAggregationService, {
|
|
4
|
+
HistogramBucket,
|
|
5
|
+
HistogramRequest,
|
|
6
|
+
} from "../../../../../Server/Services/LogAggregationService";
|
|
7
|
+
import DatabaseRequestType from "../../../../../Server/Types/BaseDatabase/DatabaseRequestType";
|
|
8
|
+
import ModelPermission from "../../../../../Server/Types/AnalyticsDatabase/ModelPermission";
|
|
9
|
+
import logger from "../../../../../Server/Utils/Logger";
|
|
10
|
+
import AIToolbox, {
|
|
11
|
+
ToolCallOutcome,
|
|
12
|
+
} from "../../../../../Server/Utils/AI/Toolbox/Index";
|
|
13
|
+
import {
|
|
14
|
+
LogHistogramTool,
|
|
15
|
+
SearchLogsTool,
|
|
16
|
+
} from "../../../../../Server/Utils/AI/Toolbox/LogTools";
|
|
17
|
+
import {
|
|
18
|
+
ToolContext,
|
|
19
|
+
ToolExecutionResult,
|
|
20
|
+
} from "../../../../../Server/Utils/AI/Toolbox/ToolTypes";
|
|
21
|
+
import {
|
|
22
|
+
AIChatCitationTargetType,
|
|
23
|
+
AIChatWidgetColumn,
|
|
24
|
+
AIChatWidgetSeries,
|
|
25
|
+
AIChatWidgetType,
|
|
26
|
+
} from "../../../../../Types/AI/AIChatTypes";
|
|
27
|
+
import DatabaseCommonInteractionProps from "../../../../../Types/BaseDatabase/DatabaseCommonInteractionProps";
|
|
28
|
+
import InBetween from "../../../../../Types/BaseDatabase/InBetween";
|
|
29
|
+
import Includes from "../../../../../Types/BaseDatabase/Includes";
|
|
30
|
+
import Search from "../../../../../Types/BaseDatabase/Search";
|
|
31
|
+
import SortOrder from "../../../../../Types/BaseDatabase/SortOrder";
|
|
32
|
+
import OneUptimeDate from "../../../../../Types/Date";
|
|
33
|
+
import BadDataException from "../../../../../Types/Exception/BadDataException";
|
|
34
|
+
import { JSONObject } from "../../../../../Types/JSON";
|
|
35
|
+
import ObjectID from "../../../../../Types/ObjectID";
|
|
36
|
+
import Permission from "../../../../../Types/Permission";
|
|
37
|
+
import { afterEach, beforeEach, describe, expect, test } from "@jest/globals";
|
|
38
|
+
|
|
39
|
+
const projectId: ObjectID = new ObjectID(
|
|
40
|
+
"11111111-1111-1111-1111-111111111111",
|
|
41
|
+
);
|
|
42
|
+
const otherProjectId: ObjectID = new ObjectID(
|
|
43
|
+
"99999999-9999-9999-9999-999999999999",
|
|
44
|
+
);
|
|
45
|
+
const serviceA: ObjectID = new ObjectID("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa");
|
|
46
|
+
const serviceB: ObjectID = new ObjectID("bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb");
|
|
47
|
+
const serviceC: ObjectID = new ObjectID("cccccccc-cccc-cccc-cccc-cccccccccccc");
|
|
48
|
+
const NOW: Date = new Date("2026-09-17T12:00:00.000Z");
|
|
49
|
+
const HOUR_MS: number = 60 * 60 * 1000;
|
|
50
|
+
|
|
51
|
+
function context(
|
|
52
|
+
allowed: Array<Permission> = [Permission.ProjectMember],
|
|
53
|
+
blocked: Array<Permission> = [],
|
|
54
|
+
): ToolContext {
|
|
55
|
+
const toUserPermission: (
|
|
56
|
+
isBlock: boolean,
|
|
57
|
+
) => (permission: Permission) => JSONObject = (
|
|
58
|
+
isBlock: boolean,
|
|
59
|
+
): ((permission: Permission) => JSONObject) => {
|
|
60
|
+
return (permission: Permission): JSONObject => {
|
|
61
|
+
return {
|
|
62
|
+
permission: permission,
|
|
63
|
+
labelIds: [],
|
|
64
|
+
isBlockPermission: isBlock,
|
|
65
|
+
_type: "UserPermission",
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
return {
|
|
70
|
+
projectId: projectId,
|
|
71
|
+
props: {
|
|
72
|
+
tenantId: projectId,
|
|
73
|
+
userId: ObjectID.generate(),
|
|
74
|
+
userGlobalAccessPermission: {
|
|
75
|
+
globalPermissions: [Permission.Public],
|
|
76
|
+
projectIds: [projectId],
|
|
77
|
+
_type: "UserGlobalAccessPermission",
|
|
78
|
+
},
|
|
79
|
+
userTenantAccessPermission: {
|
|
80
|
+
[projectId.toString()]: {
|
|
81
|
+
projectId: projectId,
|
|
82
|
+
permissions: [
|
|
83
|
+
...allowed.map(toUserPermission(false)),
|
|
84
|
+
...blocked.map(toUserPermission(true)),
|
|
85
|
+
],
|
|
86
|
+
_type: "UserTenantAccessPermission",
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
} as unknown as DatabaseCommonInteractionProps,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function makeLog(data: JSONObject): Log {
|
|
94
|
+
return data as unknown as Log;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function firstCallArg(spy: jest.SpyInstance): JSONObject {
|
|
98
|
+
return spy.mock.calls[0]![0] as JSONObject;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function queryOf(spy: jest.SpyInstance, callIndex: number = 0): JSONObject {
|
|
102
|
+
return (spy.mock.calls[callIndex]![0] as JSONObject)["query"] as JSONObject;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function histogramRequest(spy: jest.SpyInstance): HistogramRequest {
|
|
106
|
+
return spy.mock.calls[0]![0] as HistogramRequest;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
beforeEach(() => {
|
|
110
|
+
jest.spyOn(OneUptimeDate, "getCurrentDate").mockReturnValue(NOW);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
afterEach(() => {
|
|
114
|
+
jest.restoreAllMocks();
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
describe("search_logs", () => {
|
|
118
|
+
test("defaults to the last hour, 25 rows, newest first, under the caller's props", async () => {
|
|
119
|
+
const ctx: ToolContext = context();
|
|
120
|
+
const findBy: jest.SpyInstance = jest
|
|
121
|
+
.spyOn(LogService, "findBy")
|
|
122
|
+
.mockResolvedValue([]);
|
|
123
|
+
|
|
124
|
+
await SearchLogsTool.execute({}, ctx);
|
|
125
|
+
|
|
126
|
+
expect(findBy).toHaveBeenCalledTimes(1);
|
|
127
|
+
const call: JSONObject = firstCallArg(findBy);
|
|
128
|
+
expect(call["props"]).toBe(ctx.props);
|
|
129
|
+
expect(call["limit"]).toBe(25);
|
|
130
|
+
expect(call["skip"]).toBe(0);
|
|
131
|
+
expect(call["sort"]).toEqual({ time: SortOrder.Descending });
|
|
132
|
+
expect(call["select"]).toEqual({
|
|
133
|
+
time: true,
|
|
134
|
+
severityText: true,
|
|
135
|
+
body: true,
|
|
136
|
+
traceId: true,
|
|
137
|
+
spanId: true,
|
|
138
|
+
primaryEntityId: true,
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
const query: JSONObject = call["query"] as JSONObject;
|
|
142
|
+
expect(Object.keys(query)).toEqual(["time"]);
|
|
143
|
+
const time: InBetween<Date> = query["time"] as InBetween<Date>;
|
|
144
|
+
expect(time).toBeInstanceOf(InBetween);
|
|
145
|
+
expect(time.endValue).toEqual(NOW);
|
|
146
|
+
expect(time.startValue).toEqual(new Date(NOW.getTime() - HOUR_MS));
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
test("never lets arguments redirect the query to another project or tenant", async () => {
|
|
150
|
+
const ctx: ToolContext = context();
|
|
151
|
+
const findBy: jest.SpyInstance = jest
|
|
152
|
+
.spyOn(LogService, "findBy")
|
|
153
|
+
.mockResolvedValue([]);
|
|
154
|
+
|
|
155
|
+
await SearchLogsTool.execute(
|
|
156
|
+
{
|
|
157
|
+
projectId: otherProjectId.toString(),
|
|
158
|
+
tenantId: otherProjectId.toString(),
|
|
159
|
+
props: { isRoot: true },
|
|
160
|
+
},
|
|
161
|
+
ctx,
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
const call: JSONObject = firstCallArg(findBy);
|
|
165
|
+
const query: JSONObject = call["query"] as JSONObject;
|
|
166
|
+
expect(query["projectId"]).toBeUndefined();
|
|
167
|
+
expect(query["tenantId"]).toBeUndefined();
|
|
168
|
+
expect(call["props"]).toBe(ctx.props);
|
|
169
|
+
expect((call["props"] as JSONObject)["isRoot"]).toBeUndefined();
|
|
170
|
+
expect(JSON.stringify(call)).not.toContain(otherProjectId.toString());
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
test("applies severity, body, trace and service filters", async () => {
|
|
174
|
+
const findBy: jest.SpyInstance = jest
|
|
175
|
+
.spyOn(LogService, "findBy")
|
|
176
|
+
.mockResolvedValue([]);
|
|
177
|
+
|
|
178
|
+
await SearchLogsTool.execute(
|
|
179
|
+
{
|
|
180
|
+
severityTexts: ["Error", "", " ", 42, "Fatal"],
|
|
181
|
+
bodySearchText: " connection refused ",
|
|
182
|
+
traceId: " abc123 ",
|
|
183
|
+
serviceId: serviceA.toString(),
|
|
184
|
+
},
|
|
185
|
+
context(),
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
const query: JSONObject = queryOf(findBy);
|
|
189
|
+
expect(query["severityText"]).toBeInstanceOf(Includes);
|
|
190
|
+
expect((query["severityText"] as Includes).values).toEqual([
|
|
191
|
+
"Error",
|
|
192
|
+
"Fatal",
|
|
193
|
+
]);
|
|
194
|
+
expect(query["body"]).toBeInstanceOf(Search);
|
|
195
|
+
expect((query["body"] as Search<string>).value).toBe("connection refused");
|
|
196
|
+
expect(query["traceId"]).toBe("abc123");
|
|
197
|
+
expect(query["primaryEntityId"]).toBeInstanceOf(ObjectID);
|
|
198
|
+
expect((query["primaryEntityId"] as ObjectID).toString()).toBe(
|
|
199
|
+
serviceA.toString(),
|
|
200
|
+
);
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
test("ignores empty, whitespace-only and wrongly-typed filters", async () => {
|
|
204
|
+
const findBy: jest.SpyInstance = jest
|
|
205
|
+
.spyOn(LogService, "findBy")
|
|
206
|
+
.mockResolvedValue([]);
|
|
207
|
+
|
|
208
|
+
await SearchLogsTool.execute(
|
|
209
|
+
{
|
|
210
|
+
severityTexts: ["", " ", 5] as unknown as JSONObject,
|
|
211
|
+
bodySearchText: " ",
|
|
212
|
+
traceId: 12345,
|
|
213
|
+
serviceId: "",
|
|
214
|
+
},
|
|
215
|
+
context(),
|
|
216
|
+
);
|
|
217
|
+
await SearchLogsTool.execute(
|
|
218
|
+
{ severityTexts: "Error", bodySearchText: null, traceId: [] },
|
|
219
|
+
context(),
|
|
220
|
+
);
|
|
221
|
+
|
|
222
|
+
for (const index of [0, 1]) {
|
|
223
|
+
expect(Object.keys(queryOf(findBy, index))).toEqual(["time"]);
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
test.each([
|
|
228
|
+
[900, 50],
|
|
229
|
+
[50, 50],
|
|
230
|
+
[0, 1],
|
|
231
|
+
[-5, 1],
|
|
232
|
+
["10", 10],
|
|
233
|
+
[7.9, 7],
|
|
234
|
+
["not-a-number", 25],
|
|
235
|
+
[null, 25],
|
|
236
|
+
[Number.POSITIVE_INFINITY, 25],
|
|
237
|
+
])("clamps limit %p to %p", async (input: unknown, expected: number) => {
|
|
238
|
+
const findBy: jest.SpyInstance = jest
|
|
239
|
+
.spyOn(LogService, "findBy")
|
|
240
|
+
.mockResolvedValue([]);
|
|
241
|
+
|
|
242
|
+
await SearchLogsTool.execute(
|
|
243
|
+
{ limit: input } as unknown as JSONObject,
|
|
244
|
+
context(),
|
|
245
|
+
);
|
|
246
|
+
|
|
247
|
+
expect(firstCallArg(findBy)["limit"]).toBe(expected);
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
test("uses an explicit time range and clamps windows longer than 30 days", async () => {
|
|
251
|
+
const findBy: jest.SpyInstance = jest
|
|
252
|
+
.spyOn(LogService, "findBy")
|
|
253
|
+
.mockResolvedValue([]);
|
|
254
|
+
|
|
255
|
+
const start: string = "2026-09-10T00:00:00.000Z";
|
|
256
|
+
const end: string = "2026-09-10T06:00:00.000Z";
|
|
257
|
+
await SearchLogsTool.execute({ startTime: start, endTime: end }, context());
|
|
258
|
+
|
|
259
|
+
const firstTime: InBetween<Date> = queryOf(findBy, 0)[
|
|
260
|
+
"time"
|
|
261
|
+
] as InBetween<Date>;
|
|
262
|
+
expect(firstTime.startValue).toEqual(new Date(start));
|
|
263
|
+
expect(firstTime.endValue).toEqual(new Date(end));
|
|
264
|
+
|
|
265
|
+
await SearchLogsTool.execute(
|
|
266
|
+
{ startTime: "2025-01-01T00:00:00.000Z", endTime: end },
|
|
267
|
+
context(),
|
|
268
|
+
);
|
|
269
|
+
const clamped: InBetween<Date> = queryOf(findBy, 1)[
|
|
270
|
+
"time"
|
|
271
|
+
] as InBetween<Date>;
|
|
272
|
+
expect(clamped.endValue).toEqual(new Date(end));
|
|
273
|
+
expect(clamped.startValue).toEqual(
|
|
274
|
+
new Date(new Date(end).getTime() - 30 * 24 * HOUR_MS),
|
|
275
|
+
);
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
test.each([
|
|
279
|
+
[{ startTime: "yesterday-ish" }, "startTime"],
|
|
280
|
+
[{ endTime: "not a date" }, "endTime"],
|
|
281
|
+
[
|
|
282
|
+
{
|
|
283
|
+
startTime: "2026-09-10T06:00:00.000Z",
|
|
284
|
+
endTime: "2026-09-10T00:00:00.000Z",
|
|
285
|
+
},
|
|
286
|
+
"before endTime",
|
|
287
|
+
],
|
|
288
|
+
[
|
|
289
|
+
{
|
|
290
|
+
startTime: "2026-09-10T06:00:00.000Z",
|
|
291
|
+
endTime: "2026-09-10T06:00:00.000Z",
|
|
292
|
+
},
|
|
293
|
+
"before endTime",
|
|
294
|
+
],
|
|
295
|
+
])(
|
|
296
|
+
"rejects invalid time range %p without querying",
|
|
297
|
+
async (args: JSONObject, messagePart: string) => {
|
|
298
|
+
const findBy: jest.SpyInstance = jest
|
|
299
|
+
.spyOn(LogService, "findBy")
|
|
300
|
+
.mockResolvedValue([]);
|
|
301
|
+
|
|
302
|
+
await expect(SearchLogsTool.execute(args, context())).rejects.toThrow(
|
|
303
|
+
BadDataException,
|
|
304
|
+
);
|
|
305
|
+
await expect(SearchLogsTool.execute(args, context())).rejects.toThrow(
|
|
306
|
+
messagePart,
|
|
307
|
+
);
|
|
308
|
+
expect(findBy).not.toHaveBeenCalled();
|
|
309
|
+
},
|
|
310
|
+
);
|
|
311
|
+
|
|
312
|
+
test("formats rows for the model and builds a table widget from raw rows", async () => {
|
|
313
|
+
const t1: Date = new Date("2026-09-17T11:59:00.000Z");
|
|
314
|
+
const t2: Date = new Date("2026-09-17T11:58:00.000Z");
|
|
315
|
+
jest.spyOn(LogService, "findBy").mockResolvedValue([
|
|
316
|
+
makeLog({
|
|
317
|
+
time: t1,
|
|
318
|
+
severityText: "Error",
|
|
319
|
+
body: "payment failed for user jane@example.com",
|
|
320
|
+
traceId: "0af7651916cd43dd8448eb211c80319c",
|
|
321
|
+
spanId: "b7ad6b7169203331",
|
|
322
|
+
primaryEntityId: serviceA,
|
|
323
|
+
}),
|
|
324
|
+
makeLog({
|
|
325
|
+
time: t2,
|
|
326
|
+
severityText: "Info",
|
|
327
|
+
body: "healthy",
|
|
328
|
+
}),
|
|
329
|
+
]);
|
|
330
|
+
|
|
331
|
+
const result: ToolExecutionResult = await SearchLogsTool.execute(
|
|
332
|
+
{},
|
|
333
|
+
context(),
|
|
334
|
+
);
|
|
335
|
+
|
|
336
|
+
expect(result.rowCount).toBe(2);
|
|
337
|
+
expect(result.isTruncated).toBe(false);
|
|
338
|
+
const lines: Array<string> = result.dataForLlm.split("\n");
|
|
339
|
+
expect(lines).toHaveLength(2);
|
|
340
|
+
expect(lines[0]).toBe(
|
|
341
|
+
`- time=${t1.toISOString()} | severity=Error | body=payment failed for user [redacted-email] | traceId=0af7651916cd43dd8448eb211c80319c | spanId=b7ad6b7169203331`,
|
|
342
|
+
);
|
|
343
|
+
expect(lines[1]).toBe(
|
|
344
|
+
`- time=${t2.toISOString()} | severity=Info | body=healthy`,
|
|
345
|
+
);
|
|
346
|
+
// The service id is selected but not surfaced to the model.
|
|
347
|
+
expect(result.dataForLlm).not.toContain(serviceA.toString());
|
|
348
|
+
expect(result.redactionCount).toBe(1);
|
|
349
|
+
|
|
350
|
+
expect(result.citationTarget).toEqual({
|
|
351
|
+
type: AIChatCitationTargetType.Logs,
|
|
352
|
+
});
|
|
353
|
+
expect(result.citationLabel).toBe(
|
|
354
|
+
`Logs ${new Date(NOW.getTime() - HOUR_MS).toISOString()} – ${NOW.toISOString()} (2 shown)`,
|
|
355
|
+
);
|
|
356
|
+
|
|
357
|
+
expect(result.widget?.type).toBe(AIChatWidgetType.Table);
|
|
358
|
+
expect(result.widget?.title).toBe("Logs (2)");
|
|
359
|
+
expect(
|
|
360
|
+
(result.widget?.data.columns || []).map((column: AIChatWidgetColumn) => {
|
|
361
|
+
return column.key;
|
|
362
|
+
}),
|
|
363
|
+
).toEqual(["time", "severity", "body", "traceId"]);
|
|
364
|
+
const widgetRows: Array<JSONObject> = result.widget?.data[
|
|
365
|
+
"rows"
|
|
366
|
+
] as Array<JSONObject>;
|
|
367
|
+
// Widget is rendered back to the same RBAC-checked user: raw, unredacted.
|
|
368
|
+
expect(widgetRows[0]!["body"]).toBe(
|
|
369
|
+
"payment failed for user jane@example.com",
|
|
370
|
+
);
|
|
371
|
+
expect(result.widget?.data["link"]).toEqual({
|
|
372
|
+
type: AIChatCitationTargetType.Logs,
|
|
373
|
+
});
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
test("empty results produce no widget and an explicit no-rows marker", async () => {
|
|
377
|
+
jest.spyOn(LogService, "findBy").mockResolvedValue([]);
|
|
378
|
+
|
|
379
|
+
const result: ToolExecutionResult = await SearchLogsTool.execute(
|
|
380
|
+
{},
|
|
381
|
+
context(),
|
|
382
|
+
);
|
|
383
|
+
|
|
384
|
+
expect(result.rowCount).toBe(0);
|
|
385
|
+
expect(result.dataForLlm).toBe("(no rows found)");
|
|
386
|
+
expect(result.widget).toBeUndefined();
|
|
387
|
+
expect(result.citationLabel).toContain("(0 shown)");
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
test("truncates very long log bodies in the model payload", async () => {
|
|
391
|
+
jest
|
|
392
|
+
.spyOn(LogService, "findBy")
|
|
393
|
+
.mockResolvedValue([
|
|
394
|
+
makeLog({ time: NOW, severityText: "Info", body: "x".repeat(2000) }),
|
|
395
|
+
]);
|
|
396
|
+
|
|
397
|
+
const result: ToolExecutionResult = await SearchLogsTool.execute(
|
|
398
|
+
{},
|
|
399
|
+
context(),
|
|
400
|
+
);
|
|
401
|
+
|
|
402
|
+
expect(result.isTruncated).toBe(true);
|
|
403
|
+
expect(result.dataForLlm).toContain("… [truncated]");
|
|
404
|
+
expect(result.dataForLlm.length).toBeLessThan(700);
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
test("propagates service failures from execute", async () => {
|
|
408
|
+
jest
|
|
409
|
+
.spyOn(LogService, "findBy")
|
|
410
|
+
.mockRejectedValue(new Error("ClickHouse unavailable"));
|
|
411
|
+
|
|
412
|
+
await expect(SearchLogsTool.execute({}, context())).rejects.toThrow(
|
|
413
|
+
"ClickHouse unavailable",
|
|
414
|
+
);
|
|
415
|
+
});
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
describe("log_histogram", () => {
|
|
419
|
+
let getAccessible: jest.SpyInstance;
|
|
420
|
+
|
|
421
|
+
beforeEach(() => {
|
|
422
|
+
getAccessible = jest
|
|
423
|
+
.spyOn(ModelPermission, "getAccessibleServiceIdsForAnalyticsModel")
|
|
424
|
+
.mockResolvedValue(null);
|
|
425
|
+
});
|
|
426
|
+
|
|
427
|
+
test("scopes the raw aggregation to the authenticated project, not the arguments", async () => {
|
|
428
|
+
const ctx: ToolContext = context();
|
|
429
|
+
const getHistogram: jest.SpyInstance = jest
|
|
430
|
+
.spyOn(LogAggregationService, "getHistogram")
|
|
431
|
+
.mockResolvedValue([]);
|
|
432
|
+
|
|
433
|
+
await LogHistogramTool.execute(
|
|
434
|
+
{ projectId: otherProjectId.toString() },
|
|
435
|
+
ctx,
|
|
436
|
+
);
|
|
437
|
+
|
|
438
|
+
const request: HistogramRequest = histogramRequest(getHistogram);
|
|
439
|
+
expect(request.projectId).toBe(ctx.projectId);
|
|
440
|
+
expect(request.projectId.toString()).toBe(projectId.toString());
|
|
441
|
+
expect(getAccessible).toHaveBeenCalledWith(
|
|
442
|
+
Log,
|
|
443
|
+
ctx.props,
|
|
444
|
+
DatabaseRequestType.Read,
|
|
445
|
+
);
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
test("defaults to 24 hours in 30-minute buckets with no filters", async () => {
|
|
449
|
+
const getHistogram: jest.SpyInstance = jest
|
|
450
|
+
.spyOn(LogAggregationService, "getHistogram")
|
|
451
|
+
.mockResolvedValue([]);
|
|
452
|
+
|
|
453
|
+
await LogHistogramTool.execute({}, context());
|
|
454
|
+
|
|
455
|
+
const request: HistogramRequest = histogramRequest(getHistogram);
|
|
456
|
+
expect(request.endTime).toEqual(NOW);
|
|
457
|
+
expect(request.startTime).toEqual(new Date(NOW.getTime() - 24 * HOUR_MS));
|
|
458
|
+
expect(request.bucketSizeInMinutes).toBe(30);
|
|
459
|
+
expect(request.serviceIds).toBeUndefined();
|
|
460
|
+
expect(request.severityTexts).toBeUndefined();
|
|
461
|
+
expect(request.bodySearchText).toBeUndefined();
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
test.each([
|
|
465
|
+
["2026-09-17T11:30:00.000Z", 1],
|
|
466
|
+
["2026-09-17T11:59:00.000Z", 1],
|
|
467
|
+
["2026-09-17T08:00:00.000Z", 5],
|
|
468
|
+
["2026-09-17T11:00:00.000Z", 2],
|
|
469
|
+
["2026-08-18T12:00:00.000Z", 900],
|
|
470
|
+
// Longer than 30 days is clamped to 30 days first.
|
|
471
|
+
["2026-01-01T00:00:00.000Z", 900],
|
|
472
|
+
])(
|
|
473
|
+
"window starting %s uses %p-minute buckets (at most 48 buckets)",
|
|
474
|
+
async (startTime: string, expected: number) => {
|
|
475
|
+
const getHistogram: jest.SpyInstance = jest
|
|
476
|
+
.spyOn(LogAggregationService, "getHistogram")
|
|
477
|
+
.mockResolvedValue([]);
|
|
478
|
+
|
|
479
|
+
await LogHistogramTool.execute(
|
|
480
|
+
{ startTime: startTime, endTime: NOW.toISOString() },
|
|
481
|
+
context(),
|
|
482
|
+
);
|
|
483
|
+
|
|
484
|
+
const request: HistogramRequest = histogramRequest(getHistogram);
|
|
485
|
+
expect(request.bucketSizeInMinutes).toBe(expected);
|
|
486
|
+
const windowMinutes: number =
|
|
487
|
+
(request.endTime.getTime() - request.startTime.getTime()) / 60000;
|
|
488
|
+
expect(Math.ceil(windowMinutes / expected)).toBeLessThanOrEqual(48);
|
|
489
|
+
},
|
|
490
|
+
);
|
|
491
|
+
|
|
492
|
+
test("forwards severity and body filters", async () => {
|
|
493
|
+
const getHistogram: jest.SpyInstance = jest
|
|
494
|
+
.spyOn(LogAggregationService, "getHistogram")
|
|
495
|
+
.mockResolvedValue([]);
|
|
496
|
+
|
|
497
|
+
await LogHistogramTool.execute(
|
|
498
|
+
{ severityTexts: ["Error", ""], bodySearchText: " timeout " },
|
|
499
|
+
context(),
|
|
500
|
+
);
|
|
501
|
+
|
|
502
|
+
const request: HistogramRequest = histogramRequest(getHistogram);
|
|
503
|
+
expect(request.severityTexts).toEqual(["Error"]);
|
|
504
|
+
expect(request.bodySearchText).toBe("timeout");
|
|
505
|
+
});
|
|
506
|
+
|
|
507
|
+
test("project-wide users can filter to a single requested service", async () => {
|
|
508
|
+
const getHistogram: jest.SpyInstance = jest
|
|
509
|
+
.spyOn(LogAggregationService, "getHistogram")
|
|
510
|
+
.mockResolvedValue([]);
|
|
511
|
+
|
|
512
|
+
await LogHistogramTool.execute(
|
|
513
|
+
{ serviceId: serviceA.toString() },
|
|
514
|
+
context(),
|
|
515
|
+
);
|
|
516
|
+
|
|
517
|
+
const serviceIds: Array<ObjectID> | undefined =
|
|
518
|
+
histogramRequest(getHistogram).serviceIds;
|
|
519
|
+
expect(serviceIds?.map(String)).toEqual([serviceA.toString()]);
|
|
520
|
+
});
|
|
521
|
+
|
|
522
|
+
test("label-restricted users only ever see their accessible services", async () => {
|
|
523
|
+
getAccessible.mockResolvedValue([serviceA, serviceB]);
|
|
524
|
+
const getHistogram: jest.SpyInstance = jest
|
|
525
|
+
.spyOn(LogAggregationService, "getHistogram")
|
|
526
|
+
.mockResolvedValue([]);
|
|
527
|
+
|
|
528
|
+
await LogHistogramTool.execute({}, context());
|
|
529
|
+
await LogHistogramTool.execute(
|
|
530
|
+
{ serviceId: serviceB.toString() },
|
|
531
|
+
context(),
|
|
532
|
+
);
|
|
533
|
+
await LogHistogramTool.execute(
|
|
534
|
+
{ serviceId: serviceC.toString() },
|
|
535
|
+
context(),
|
|
536
|
+
);
|
|
537
|
+
|
|
538
|
+
const idsForCall: (index: number) => Array<string> = (
|
|
539
|
+
index: number,
|
|
540
|
+
): Array<string> => {
|
|
541
|
+
return (
|
|
542
|
+
(getHistogram.mock.calls[index]![0] as HistogramRequest).serviceIds ||
|
|
543
|
+
[]
|
|
544
|
+
).map(String);
|
|
545
|
+
};
|
|
546
|
+
|
|
547
|
+
expect(idsForCall(0)).toEqual([serviceA.toString(), serviceB.toString()]);
|
|
548
|
+
expect(idsForCall(1)).toEqual([serviceB.toString()]);
|
|
549
|
+
// An inaccessible service must not widen to "no filter" (whole project).
|
|
550
|
+
expect(idsForCall(2)).toEqual([ObjectID.getZeroObjectID().toString()]);
|
|
551
|
+
});
|
|
552
|
+
|
|
553
|
+
test("users with no accessible services get a no-match sentinel, never an unfiltered query", async () => {
|
|
554
|
+
getAccessible.mockResolvedValue([]);
|
|
555
|
+
const getHistogram: jest.SpyInstance = jest
|
|
556
|
+
.spyOn(LogAggregationService, "getHistogram")
|
|
557
|
+
.mockResolvedValue([]);
|
|
558
|
+
|
|
559
|
+
await LogHistogramTool.execute({}, context());
|
|
560
|
+
|
|
561
|
+
const serviceIds: Array<ObjectID> | undefined =
|
|
562
|
+
histogramRequest(getHistogram).serviceIds;
|
|
563
|
+
expect(serviceIds).toBeDefined();
|
|
564
|
+
expect(serviceIds?.map(String)).toEqual([
|
|
565
|
+
ObjectID.getZeroObjectID().toString(),
|
|
566
|
+
]);
|
|
567
|
+
});
|
|
568
|
+
|
|
569
|
+
test("pivots (bucket, severity) rows into one sorted row per bucket and a stacked bar chart", async () => {
|
|
570
|
+
const buckets: Array<HistogramBucket> = [
|
|
571
|
+
{ time: "2026-09-17 11:30:00", severity: "Error", count: 12 },
|
|
572
|
+
{ time: "2026-09-17 11:00:00", severity: "Info", count: 100 },
|
|
573
|
+
{ time: "2026-09-17 11:30:00", severity: "Warn", count: 3 },
|
|
574
|
+
{ time: "2026-09-17 11:00:00", severity: "", count: 4 },
|
|
575
|
+
];
|
|
576
|
+
jest
|
|
577
|
+
.spyOn(LogAggregationService, "getHistogram")
|
|
578
|
+
.mockResolvedValue(buckets);
|
|
579
|
+
|
|
580
|
+
const result: ToolExecutionResult = await LogHistogramTool.execute(
|
|
581
|
+
{},
|
|
582
|
+
context(),
|
|
583
|
+
);
|
|
584
|
+
|
|
585
|
+
expect(result.rowCount).toBe(2);
|
|
586
|
+
expect(result.dataForLlm).toBe(
|
|
587
|
+
[
|
|
588
|
+
"- time=2026-09-17 11:00:00 | Info=100 | Unspecified=4",
|
|
589
|
+
"- time=2026-09-17 11:30:00 | Error=12 | Warn=3",
|
|
590
|
+
].join("\n"),
|
|
591
|
+
);
|
|
592
|
+
expect(result.citationTarget).toEqual({
|
|
593
|
+
type: AIChatCitationTargetType.Logs,
|
|
594
|
+
});
|
|
595
|
+
expect(result.citationLabel).toBe(
|
|
596
|
+
`Log volume by severity, ${new Date(NOW.getTime() - 24 * HOUR_MS).toISOString()} – ${NOW.toISOString()}`,
|
|
597
|
+
);
|
|
598
|
+
|
|
599
|
+
expect(result.widget?.type).toBe(AIChatWidgetType.BarChart);
|
|
600
|
+
expect(result.widget?.data["stacked"]).toBe(true);
|
|
601
|
+
expect(result.widget?.data["xIsTime"]).toBe(true);
|
|
602
|
+
expect(result.widget?.data["unit"]).toBe("logs");
|
|
603
|
+
const series: Array<AIChatWidgetSeries> | undefined =
|
|
604
|
+
result.widget?.data.series;
|
|
605
|
+
expect(series).toEqual([
|
|
606
|
+
{
|
|
607
|
+
name: "Info",
|
|
608
|
+
points: [
|
|
609
|
+
{ x: "2026-09-17 11:00:00", y: 100 },
|
|
610
|
+
{ x: "2026-09-17 11:30:00", y: 0 },
|
|
611
|
+
],
|
|
612
|
+
},
|
|
613
|
+
{
|
|
614
|
+
name: "Unspecified",
|
|
615
|
+
points: [
|
|
616
|
+
{ x: "2026-09-17 11:00:00", y: 4 },
|
|
617
|
+
{ x: "2026-09-17 11:30:00", y: 0 },
|
|
618
|
+
],
|
|
619
|
+
},
|
|
620
|
+
{
|
|
621
|
+
name: "Error",
|
|
622
|
+
points: [
|
|
623
|
+
{ x: "2026-09-17 11:00:00", y: 0 },
|
|
624
|
+
{ x: "2026-09-17 11:30:00", y: 12 },
|
|
625
|
+
],
|
|
626
|
+
},
|
|
627
|
+
{
|
|
628
|
+
name: "Warn",
|
|
629
|
+
points: [
|
|
630
|
+
{ x: "2026-09-17 11:00:00", y: 0 },
|
|
631
|
+
{ x: "2026-09-17 11:30:00", y: 3 },
|
|
632
|
+
],
|
|
633
|
+
},
|
|
634
|
+
]);
|
|
635
|
+
});
|
|
636
|
+
|
|
637
|
+
test("a full 48-bucket window is never truncated by the serializer row cap", async () => {
|
|
638
|
+
const buckets: Array<HistogramBucket> = [];
|
|
639
|
+
for (let i: number = 0; i < 48; i++) {
|
|
640
|
+
const time: string = `bucket-${String(i).padStart(2, "0")}`;
|
|
641
|
+
buckets.push({ time: time, severity: "Error", count: i });
|
|
642
|
+
buckets.push({ time: time, severity: "Info", count: i * 2 });
|
|
643
|
+
}
|
|
644
|
+
jest
|
|
645
|
+
.spyOn(LogAggregationService, "getHistogram")
|
|
646
|
+
.mockResolvedValue(buckets);
|
|
647
|
+
|
|
648
|
+
const result: ToolExecutionResult = await LogHistogramTool.execute(
|
|
649
|
+
{},
|
|
650
|
+
context(),
|
|
651
|
+
);
|
|
652
|
+
|
|
653
|
+
expect(result.rowCount).toBe(48);
|
|
654
|
+
expect(result.isTruncated).toBe(false);
|
|
655
|
+
expect(result.dataForLlm).toContain("time=bucket-47 | Error=47 | Info=94");
|
|
656
|
+
});
|
|
657
|
+
|
|
658
|
+
test("empty histograms produce no widget", async () => {
|
|
659
|
+
jest.spyOn(LogAggregationService, "getHistogram").mockResolvedValue([]);
|
|
660
|
+
|
|
661
|
+
const result: ToolExecutionResult = await LogHistogramTool.execute(
|
|
662
|
+
{},
|
|
663
|
+
context(),
|
|
664
|
+
);
|
|
665
|
+
|
|
666
|
+
expect(result.rowCount).toBe(0);
|
|
667
|
+
expect(result.dataForLlm).toBe("(no rows found)");
|
|
668
|
+
expect(result.widget).toBeUndefined();
|
|
669
|
+
});
|
|
670
|
+
|
|
671
|
+
test("fails closed when the owned-scope lookup fails", async () => {
|
|
672
|
+
getAccessible.mockRejectedValue(new Error("scope lookup failed"));
|
|
673
|
+
const getHistogram: jest.SpyInstance = jest
|
|
674
|
+
.spyOn(LogAggregationService, "getHistogram")
|
|
675
|
+
.mockResolvedValue([]);
|
|
676
|
+
|
|
677
|
+
await expect(LogHistogramTool.execute({}, context())).rejects.toThrow(
|
|
678
|
+
"scope lookup failed",
|
|
679
|
+
);
|
|
680
|
+
expect(getHistogram).not.toHaveBeenCalled();
|
|
681
|
+
});
|
|
682
|
+
|
|
683
|
+
test("rejects invalid timestamps before resolving scope or querying", async () => {
|
|
684
|
+
const getHistogram: jest.SpyInstance = jest
|
|
685
|
+
.spyOn(LogAggregationService, "getHistogram")
|
|
686
|
+
.mockResolvedValue([]);
|
|
687
|
+
|
|
688
|
+
await expect(
|
|
689
|
+
LogHistogramTool.execute({ endTime: "garbage" }, context()),
|
|
690
|
+
).rejects.toThrow(BadDataException);
|
|
691
|
+
expect(getAccessible).not.toHaveBeenCalled();
|
|
692
|
+
expect(getHistogram).not.toHaveBeenCalled();
|
|
693
|
+
});
|
|
694
|
+
});
|
|
695
|
+
|
|
696
|
+
describe("log tools through the AI toolbox gate", () => {
|
|
697
|
+
test("both tools are registered and read-only", () => {
|
|
698
|
+
expect(AIToolbox.getToolByName("search_logs")).toBe(SearchLogsTool);
|
|
699
|
+
expect(AIToolbox.getToolByName("log_histogram")).toBe(LogHistogramTool);
|
|
700
|
+
expect(AIToolbox.isMutationTool("search_logs")).toBe(false);
|
|
701
|
+
expect(AIToolbox.isMutationTool("log_histogram")).toBe(false);
|
|
702
|
+
});
|
|
703
|
+
|
|
704
|
+
test.each([
|
|
705
|
+
Permission.ProjectMember,
|
|
706
|
+
Permission.Viewer,
|
|
707
|
+
Permission.TelemetryViewer,
|
|
708
|
+
Permission.ReadTelemetryServiceLog,
|
|
709
|
+
])("grants log tools to %s", (permission: Permission) => {
|
|
710
|
+
for (const tool of [SearchLogsTool, LogHistogramTool]) {
|
|
711
|
+
expect(AIToolbox.hasPermissionForTool(tool, context([permission]))).toBe(
|
|
712
|
+
true,
|
|
713
|
+
);
|
|
714
|
+
}
|
|
715
|
+
});
|
|
716
|
+
|
|
717
|
+
test("denies users without a log read permission or with a blocked one", () => {
|
|
718
|
+
for (const tool of [SearchLogsTool, LogHistogramTool]) {
|
|
719
|
+
expect(AIToolbox.hasPermissionForTool(tool, context([]))).toBe(false);
|
|
720
|
+
expect(
|
|
721
|
+
AIToolbox.hasPermissionForTool(
|
|
722
|
+
tool,
|
|
723
|
+
context([Permission.SecurityViewer]),
|
|
724
|
+
),
|
|
725
|
+
).toBe(false);
|
|
726
|
+
expect(
|
|
727
|
+
AIToolbox.hasPermissionForTool(
|
|
728
|
+
tool,
|
|
729
|
+
context([Permission.ProjectMember], [Permission.ProjectMember]),
|
|
730
|
+
),
|
|
731
|
+
).toBe(false);
|
|
732
|
+
}
|
|
733
|
+
});
|
|
734
|
+
|
|
735
|
+
test.each(["search_logs", "log_histogram"])(
|
|
736
|
+
"%s refuses cross-project and multi-tenant contexts without querying",
|
|
737
|
+
async (name: string) => {
|
|
738
|
+
const findBy: jest.SpyInstance = jest
|
|
739
|
+
.spyOn(LogService, "findBy")
|
|
740
|
+
.mockResolvedValue([]);
|
|
741
|
+
const getHistogram: jest.SpyInstance = jest
|
|
742
|
+
.spyOn(LogAggregationService, "getHistogram")
|
|
743
|
+
.mockResolvedValue([]);
|
|
744
|
+
const ctx: ToolContext = context();
|
|
745
|
+
|
|
746
|
+
const crossProject: ToolCallOutcome = await AIToolbox.executeTool({
|
|
747
|
+
name: name,
|
|
748
|
+
args: {},
|
|
749
|
+
ctx: { ...ctx, projectId: otherProjectId },
|
|
750
|
+
});
|
|
751
|
+
const multiTenant: ToolCallOutcome = await AIToolbox.executeTool({
|
|
752
|
+
name: name,
|
|
753
|
+
args: {},
|
|
754
|
+
ctx: { ...ctx, props: { ...ctx.props, isMultiTenantRequest: true } },
|
|
755
|
+
});
|
|
756
|
+
const noPermission: ToolCallOutcome = await AIToolbox.executeTool({
|
|
757
|
+
name: name,
|
|
758
|
+
args: {},
|
|
759
|
+
ctx: context([]),
|
|
760
|
+
});
|
|
761
|
+
|
|
762
|
+
expect(crossProject.success).toBe(false);
|
|
763
|
+
expect(multiTenant.success).toBe(false);
|
|
764
|
+
expect(noPermission.success).toBe(false);
|
|
765
|
+
expect(noPermission.textForLlm).toContain("does not have permission");
|
|
766
|
+
expect(findBy).not.toHaveBeenCalled();
|
|
767
|
+
expect(getHistogram).not.toHaveBeenCalled();
|
|
768
|
+
},
|
|
769
|
+
);
|
|
770
|
+
|
|
771
|
+
test("surfaces bad arguments to the model as a recoverable error", async () => {
|
|
772
|
+
// executeTool races the tool against a 45s timeout timer; keep it fake.
|
|
773
|
+
jest.useFakeTimers({ doNotFake: ["nextTick", "setImmediate"] });
|
|
774
|
+
jest.spyOn(logger, "error").mockImplementation(() => {
|
|
775
|
+
return undefined;
|
|
776
|
+
});
|
|
777
|
+
const findBy: jest.SpyInstance = jest
|
|
778
|
+
.spyOn(LogService, "findBy")
|
|
779
|
+
.mockResolvedValue([]);
|
|
780
|
+
|
|
781
|
+
const outcome: ToolCallOutcome = await AIToolbox.executeTool({
|
|
782
|
+
name: "search_logs",
|
|
783
|
+
args: { startTime: "last tuesday" },
|
|
784
|
+
ctx: context(),
|
|
785
|
+
});
|
|
786
|
+
|
|
787
|
+
expect(outcome.success).toBe(false);
|
|
788
|
+
expect(outcome.errorMessage).toContain("not a valid ISO 8601 timestamp");
|
|
789
|
+
expect(outcome.textForLlm).toContain("Error executing search_logs");
|
|
790
|
+
expect(findBy).not.toHaveBeenCalled();
|
|
791
|
+
jest.clearAllTimers();
|
|
792
|
+
jest.useRealTimers();
|
|
793
|
+
});
|
|
794
|
+
});
|