@oneuptime/common 11.3.25 → 11.3.28
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/AIConversation.ts +322 -0
- package/Models/DatabaseModels/AIConversationMessage.ts +495 -0
- package/Models/DatabaseModels/AIRun.ts +584 -0
- package/Models/DatabaseModels/AIRunEvent.ts +443 -0
- package/Models/DatabaseModels/IncidentEpisodeRoleMember.ts +1 -1
- package/Models/DatabaseModels/IncidentMember.ts +1 -1
- package/Models/DatabaseModels/IncomingCallPolicy.ts +13 -0
- package/Models/DatabaseModels/Index.ts +11 -0
- package/Models/DatabaseModels/LlmLog.ts +26 -0
- package/Models/DatabaseModels/LlmProvider.ts +2 -2
- package/Models/DatabaseModels/MigrationFailure.ts +170 -0
- package/Models/DatabaseModels/OnCallDutyPolicyExecutionLog.ts +51 -2
- package/Models/DatabaseModels/OnCallDutyPolicySchedule.ts +44 -0
- package/Models/DatabaseModels/OnCallDutyPolicyScheduleLayer.ts +6 -0
- package/Models/DatabaseModels/OnCallDutyPolicyScheduleLayerUser.ts +6 -0
- package/Models/DatabaseModels/OnCallDutyPolicyTimeLog.ts +1 -1
- package/Models/DatabaseModels/OnCallDutyPolicyUserOverride.ts +2 -2
- package/Server/API/AIChatAPI.ts +693 -0
- package/Server/API/AlertAPI.ts +1 -1
- package/Server/API/IncidentAPI.ts +2 -2
- package/Server/API/IncidentEpisodeAPI.ts +1 -1
- package/Server/API/LlmProviderAPI.ts +170 -0
- package/Server/API/MicrosoftTeamsAPI.ts +5 -0
- package/Server/API/ScheduledMaintenanceAPI.ts +1 -1
- package/Server/API/SlackAPI.ts +663 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1783363279075-AddAIChatModels.ts +245 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1783443471795-AddLlmProviderToAIConversation.ts +36 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1783453297388-AddAIChatWriteActionsAndWidgets.ts +46 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1783461767405-MigrationName.ts +119 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1783470000000-AddIncomingCallPolicyRoutingPhoneNumberUnique.ts +25 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1783510935686-FixNotNullForeignKeysOnDelete.ts +81 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1783515836148-MigrationName.ts +25 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1783523076215-AddMigrationFailureTable.ts +35 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +16 -0
- package/Server/Infrastructure/PostgresDatabase.ts +11 -0
- package/Server/Services/AIConversationMessageService.ts +39 -0
- package/Server/Services/AIConversationService.ts +63 -0
- package/Server/Services/AIRunEventService.ts +39 -0
- package/Server/Services/AIRunService.ts +39 -0
- package/Server/Services/AIService.ts +127 -33
- package/Server/Services/AnalyticsDatabaseService.ts +10 -1
- package/Server/Services/DatabaseService.ts +29 -1
- package/Server/Services/IncidentService.ts +1 -1
- package/Server/Services/IncomingCallPolicyEscalationRuleService.ts +75 -2
- package/Server/Services/IncomingCallPolicyService.ts +42 -1
- package/Server/Services/Index.ts +2 -0
- package/Server/Services/LlmProviderService.ts +110 -0
- package/Server/Services/MigrationFailureService.ts +9 -0
- package/Server/Services/MonitorProbeService.ts +33 -7
- package/Server/Services/MonitorService.ts +19 -7
- package/Server/Services/OnCallDutyPolicyEscalationRuleScheduleService.ts +65 -0
- package/Server/Services/OnCallDutyPolicyEscalationRuleService.ts +185 -41
- package/Server/Services/OnCallDutyPolicyEscalationRuleUserService.ts +23 -15
- package/Server/Services/OnCallDutyPolicyExecutionLogService.ts +39 -0
- package/Server/Services/OnCallDutyPolicyScheduleLayerService.ts +148 -0
- package/Server/Services/OnCallDutyPolicyScheduleLayerUserService.ts +11 -2
- package/Server/Services/OnCallDutyPolicyScheduleService.ts +502 -26
- package/Server/Services/OnCallDutyPolicyTimeLogService.ts +49 -7
- package/Server/Services/OnCallDutyPolicyUserOverrideService.ts +218 -4
- package/Server/Services/ProjectCallSMSConfigService.ts +82 -1
- package/Server/Services/ProjectService.ts +24 -0
- package/Server/Services/TeamMemberService.ts +6 -0
- package/Server/Services/UserNotificationRuleService.ts +13 -42
- package/Server/Services/UserOnCallLogService.ts +90 -0
- package/Server/Services/UserOnCallLogTimelineService.ts +43 -1
- package/Server/Types/AnalyticsDatabase/ModelPermission.ts +74 -9
- package/Server/Types/Database/QueryUtil.ts +57 -0
- package/Server/Utils/AI/AIChatPrivacyFilter.ts +28 -0
- package/Server/Utils/AI/AlertAIContextBuilder.ts +6 -1
- package/Server/Utils/AI/Chat/ChatAgentRunner.ts +1066 -0
- package/Server/Utils/AI/Chat/ObservabilityAssistant.ts +239 -0
- package/Server/Utils/AI/Chat/ObservabilityChatPrompt.ts +51 -0
- package/Server/Utils/AI/IncidentAIContextBuilder.ts +18 -3
- package/Server/Utils/AI/IncidentEpisodeAIContextBuilder.ts +6 -1
- package/Server/Utils/AI/ScheduledMaintenanceAIContextBuilder.ts +12 -2
- package/Server/Utils/AI/Toolbox/AlertTools.ts +201 -0
- package/Server/Utils/AI/Toolbox/AlertWriteTools.ts +174 -0
- package/Server/Utils/AI/Toolbox/ContextTools.ts +189 -0
- package/Server/Utils/AI/Toolbox/ExceptionTools.ts +149 -0
- package/Server/Utils/AI/Toolbox/IncidentTools.ts +386 -0
- package/Server/Utils/AI/Toolbox/IncidentWriteTools.ts +350 -0
- package/Server/Utils/AI/Toolbox/Index.ts +231 -0
- package/Server/Utils/AI/Toolbox/LogTools.ts +339 -0
- package/Server/Utils/AI/Toolbox/MetricTools.ts +179 -0
- package/Server/Utils/AI/Toolbox/MonitorTools.ts +193 -0
- package/Server/Utils/AI/Toolbox/RecentChangesTools.ts +208 -0
- package/Server/Utils/AI/Toolbox/Serializer.ts +299 -0
- package/Server/Utils/AI/Toolbox/ToolTypes.ts +249 -0
- package/Server/Utils/AI/Toolbox/TraceTools.ts +402 -0
- package/Server/Utils/AI/Toolbox/WidgetBuilder.ts +189 -0
- package/Server/Utils/Database/MigrationFailureLog.ts +240 -0
- package/Server/Utils/IncomingCallPhoneNumber.ts +41 -0
- package/Server/Utils/LLM/LLMService.ts +605 -96
- package/Server/Utils/Telemetry/IoTSnapshotScan.ts +12 -9
- package/Server/Utils/Telemetry/ProxmoxCephSnapshotScan.ts +12 -9
- package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.ts +512 -19
- package/Server/Utils/Workspace/Slack/Slack.ts +80 -0
- package/Server/Utils/Workspace/Slack/app-manifest.json +16 -1
- package/Tests/Server/Services/AnalyticsDatabaseService.test.ts +0 -8
- package/Tests/Server/Services/OnCallDutyPolicyScheduleLayerUserReorder.test.ts +233 -0
- package/Tests/Server/Services/OnCallDutyPolicyTimeLogServiceScoping.test.ts +242 -0
- package/Tests/Server/Services/OnCallDutyPolicyUserOverrideEdit.test.ts +198 -0
- package/Tests/Server/Services/UserOnCallLogClaimNotificationRule.test.ts +495 -0
- package/Tests/Server/Types/Database/QueryUtil.test.ts +74 -0
- package/Tests/Server/Utils/AI/AIChatModelACL.test.ts +42 -0
- package/Tests/Server/Utils/AI/ChatAgentHelpers.test.ts +89 -0
- package/Tests/Server/Utils/AI/LLMServiceBaseUrl.test.ts +139 -0
- package/Tests/Server/Utils/AI/LLMServiceToolCalling.test.ts +386 -0
- package/Tests/Server/Utils/AI/ToolArgsGetTimeRange.test.ts +62 -0
- package/Tests/Server/Utils/AI/ToolArgsScopeServiceIds.test.ts +79 -0
- package/Tests/Server/Utils/AI/ToolResultSerializer.test.ts +223 -0
- package/Tests/Types/Billing/SubscriptionStatus.test.ts +127 -0
- package/Tests/Types/DateExhaustiveTimezone.test.ts +700 -0
- package/Tests/Types/DateTimezoneWallClock.test.ts +99 -0
- package/Tests/Types/Events/Recurring.test.ts +22 -9
- package/Tests/Types/Metrics/RecordingRuleDefinition.test.ts +213 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilAuditFixes.test.ts +291 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilAuditFixesRound2.test.ts +398 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilDSTWeekendGap.test.ts +114 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilDSTWeeklyDayShift.test.ts +76 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilDailyMutation.test.ts +128 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilDailyProbe.test.ts +203 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilDiffFuzz.test.ts +322 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilEdgeCases.test.ts +280 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilExhaustiveCurrentUser.test.ts +863 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilExhaustiveDaily.test.ts +900 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilExhaustiveMultiLayer.test.ts +1104 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilExhaustiveRotation.test.ts +957 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilExhaustiveWeekly.test.ts +1095 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilInvariants.test.ts +232 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilMergeAudit.test.ts +227 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilMonthYearAudit.test.ts +255 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilMultiLayerAudit.test.ts +388 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilMultiLayerEdge.test.ts +300 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilOvernightDSTAudit.test.ts +158 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilRestrictedGapFix.test.ts +253 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilRestrictedGapRepro.test.ts +157 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilRotationFixes.test.ts +414 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilTimezone.test.ts +243 -0
- package/Tests/Types/OnCallDutyPolicy/LayerUtilWeekendGapRepro.test.ts +112 -0
- package/Tests/Types/OnCallDutyPolicy/OverrideLensAudit.test.ts +117 -0
- package/Tests/Types/OnCallDutyPolicy/RestrictionTimes.test.ts +8 -6
- package/Tests/Types/OnCallDutyPolicy/RestrictionTimesDefaultDayAudit.test.ts +112 -0
- package/Tests/Types/OnCallDutyPolicy/RestrictionTimesExhaustive.test.ts +821 -0
- package/Tests/Types/OnCallDutyPolicy/RestrictionTimesMutationInvariant.test.ts +886 -0
- package/Tests/Types/OnCallDutyPolicy/UserOverrideUtil.test.ts +255 -0
- package/Tests/Types/OnCallDutyPolicy/UserOverrideUtilExhaustive.test.ts +1126 -0
- package/Types/AI/AIChatMessageRole.ts +6 -0
- package/Types/AI/AIChatMessageStatus.ts +32 -0
- package/Types/AI/AIChatPermissionMode.ts +69 -0
- package/Types/AI/AIChatTypes.ts +231 -0
- package/Types/AI/AIRunEventType.ts +17 -0
- package/Types/AI/AIRunStatus.ts +28 -0
- package/Types/AI/AIRunType.ts +6 -0
- package/Types/Date.ts +200 -15
- package/Types/LLM/LlmType.ts +6 -0
- package/Types/OnCallDutyPolicy/Layer.ts +790 -260
- package/Types/OnCallDutyPolicy/RestrictionTimes.ts +39 -13
- package/Types/OnCallDutyPolicy/UserOverrideUtil.ts +21 -5
- package/UI/Components/Events/RecurringFieldElement.tsx +16 -0
- package/UI/Components/Header/HeaderIconDropdownButton.tsx +22 -12
- package/UI/Components/Markdown.tsx/MarkdownViewer.tsx +35 -3
- package/UI/Components/ModelFormModal/ModelFormModal.tsx +8 -0
- package/UI/Components/Page/Page.tsx +14 -0
- package/UI/Components/RadioButtons/BasicRadioButtons.tsx +1 -1
- package/UI/Utils/LlmTypeDropdownOptions.ts +40 -0
- package/UI/Utils/TestLLMProvider.ts +59 -0
- package/build/dist/Models/DatabaseModels/AIConversation.js +345 -0
- package/build/dist/Models/DatabaseModels/AIConversation.js.map +1 -0
- package/build/dist/Models/DatabaseModels/AIConversationMessage.js +521 -0
- package/build/dist/Models/DatabaseModels/AIConversationMessage.js.map +1 -0
- package/build/dist/Models/DatabaseModels/AIRun.js +619 -0
- package/build/dist/Models/DatabaseModels/AIRun.js.map +1 -0
- package/build/dist/Models/DatabaseModels/AIRunEvent.js +469 -0
- package/build/dist/Models/DatabaseModels/AIRunEvent.js.map +1 -0
- package/build/dist/Models/DatabaseModels/IncidentEpisodeRoleMember.js +1 -1
- package/build/dist/Models/DatabaseModels/IncidentEpisodeRoleMember.js.map +1 -1
- package/build/dist/Models/DatabaseModels/IncidentMember.js +1 -1
- package/build/dist/Models/DatabaseModels/IncidentMember.js.map +1 -1
- package/build/dist/Models/DatabaseModels/IncomingCallPolicy.js +10 -0
- package/build/dist/Models/DatabaseModels/IncomingCallPolicy.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Index.js +10 -0
- package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
- package/build/dist/Models/DatabaseModels/LlmLog.js +28 -0
- package/build/dist/Models/DatabaseModels/LlmLog.js.map +1 -1
- package/build/dist/Models/DatabaseModels/LlmProvider.js +2 -2
- package/build/dist/Models/DatabaseModels/LlmProvider.js.map +1 -1
- package/build/dist/Models/DatabaseModels/MigrationFailure.js +196 -0
- package/build/dist/Models/DatabaseModels/MigrationFailure.js.map +1 -0
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyExecutionLog.js +52 -2
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyExecutionLog.js.map +1 -1
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicySchedule.js +45 -0
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicySchedule.js.map +1 -1
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyScheduleLayer.js +6 -0
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyScheduleLayer.js.map +1 -1
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyScheduleLayerUser.js +6 -0
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyScheduleLayerUser.js.map +1 -1
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyTimeLog.js +1 -1
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyTimeLog.js.map +1 -1
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyUserOverride.js +2 -2
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyUserOverride.js.map +1 -1
- package/build/dist/Server/API/AIChatAPI.js +498 -0
- package/build/dist/Server/API/AIChatAPI.js.map +1 -0
- package/build/dist/Server/API/AlertAPI.js +1 -1
- package/build/dist/Server/API/IncidentAPI.js +2 -2
- package/build/dist/Server/API/IncidentEpisodeAPI.js +1 -1
- package/build/dist/Server/API/LlmProviderAPI.js +108 -1
- package/build/dist/Server/API/LlmProviderAPI.js.map +1 -1
- package/build/dist/Server/API/MicrosoftTeamsAPI.js +4 -0
- package/build/dist/Server/API/MicrosoftTeamsAPI.js.map +1 -1
- package/build/dist/Server/API/ScheduledMaintenanceAPI.js +1 -1
- package/build/dist/Server/API/SlackAPI.js +442 -0
- package/build/dist/Server/API/SlackAPI.js.map +1 -1
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783363279075-AddAIChatModels.js +96 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783363279075-AddAIChatModels.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783443471795-AddLlmProviderToAIConversation.js +25 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783443471795-AddLlmProviderToAIConversation.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783453297388-AddAIChatWriteActionsAndWidgets.js +31 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783453297388-AddAIChatWriteActionsAndWidgets.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783461767405-MigrationName.js +46 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783461767405-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783470000000-AddIncomingCallPolicyRoutingPhoneNumberUnique.js +18 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783470000000-AddIncomingCallPolicyRoutingPhoneNumberUnique.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783510935686-FixNotNullForeignKeysOnDelete.js +38 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783510935686-FixNotNullForeignKeysOnDelete.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783515836148-MigrationName.js +16 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783515836148-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783523076215-AddMigrationFailureTable.js +18 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783523076215-AddMigrationFailureTable.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +16 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Infrastructure/PostgresDatabase.js +9 -0
- package/build/dist/Server/Infrastructure/PostgresDatabase.js.map +1 -1
- package/build/dist/Server/Services/AIConversationMessageService.js +34 -0
- package/build/dist/Server/Services/AIConversationMessageService.js.map +1 -0
- package/build/dist/Server/Services/AIConversationService.js +42 -0
- package/build/dist/Server/Services/AIConversationService.js.map +1 -0
- package/build/dist/Server/Services/AIRunEventService.js +34 -0
- package/build/dist/Server/Services/AIRunEventService.js.map +1 -0
- package/build/dist/Server/Services/AIRunService.js +34 -0
- package/build/dist/Server/Services/AIRunService.js.map +1 -0
- package/build/dist/Server/Services/AIService.js +84 -25
- package/build/dist/Server/Services/AIService.js.map +1 -1
- package/build/dist/Server/Services/AnalyticsDatabaseService.js +10 -1
- package/build/dist/Server/Services/AnalyticsDatabaseService.js.map +1 -1
- package/build/dist/Server/Services/DatabaseService.js +20 -1
- package/build/dist/Server/Services/DatabaseService.js.map +1 -1
- package/build/dist/Server/Services/IncidentService.js +1 -1
- package/build/dist/Server/Services/IncomingCallPolicyEscalationRuleService.js +55 -2
- package/build/dist/Server/Services/IncomingCallPolicyEscalationRuleService.js.map +1 -1
- package/build/dist/Server/Services/IncomingCallPolicyService.js +40 -0
- package/build/dist/Server/Services/IncomingCallPolicyService.js.map +1 -1
- package/build/dist/Server/Services/Index.js +2 -0
- package/build/dist/Server/Services/Index.js.map +1 -1
- package/build/dist/Server/Services/LlmProviderService.js +108 -0
- package/build/dist/Server/Services/LlmProviderService.js.map +1 -1
- package/build/dist/Server/Services/MigrationFailureService.js +9 -0
- package/build/dist/Server/Services/MigrationFailureService.js.map +1 -0
- package/build/dist/Server/Services/MonitorProbeService.js +33 -7
- package/build/dist/Server/Services/MonitorProbeService.js.map +1 -1
- package/build/dist/Server/Services/MonitorService.js +12 -5
- package/build/dist/Server/Services/MonitorService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleScheduleService.js +81 -22
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleScheduleService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleService.js +134 -31
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleUserService.js +21 -13
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleUserService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogService.js +36 -0
- package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyScheduleLayerService.js +121 -0
- package/build/dist/Server/Services/OnCallDutyPolicyScheduleLayerService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyScheduleLayerUserService.js +11 -2
- package/build/dist/Server/Services/OnCallDutyPolicyScheduleLayerUserService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyScheduleService.js +409 -36
- package/build/dist/Server/Services/OnCallDutyPolicyScheduleService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyTimeLogService.js +52 -8
- package/build/dist/Server/Services/OnCallDutyPolicyTimeLogService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyUserOverrideService.js +170 -3
- package/build/dist/Server/Services/OnCallDutyPolicyUserOverrideService.js.map +1 -1
- package/build/dist/Server/Services/ProjectCallSMSConfigService.js +72 -0
- package/build/dist/Server/Services/ProjectCallSMSConfigService.js.map +1 -1
- package/build/dist/Server/Services/ProjectService.js +25 -0
- package/build/dist/Server/Services/ProjectService.js.map +1 -1
- package/build/dist/Server/Services/TeamMemberService.js +6 -0
- package/build/dist/Server/Services/TeamMemberService.js.map +1 -1
- package/build/dist/Server/Services/UserNotificationRuleService.js +12 -30
- package/build/dist/Server/Services/UserNotificationRuleService.js.map +1 -1
- package/build/dist/Server/Services/UserOnCallLogService.js +75 -0
- package/build/dist/Server/Services/UserOnCallLogService.js.map +1 -1
- package/build/dist/Server/Services/UserOnCallLogTimelineService.js +31 -1
- package/build/dist/Server/Services/UserOnCallLogTimelineService.js.map +1 -1
- package/build/dist/Server/Types/AnalyticsDatabase/ModelPermission.js +50 -7
- package/build/dist/Server/Types/AnalyticsDatabase/ModelPermission.js.map +1 -1
- package/build/dist/Server/Types/Database/QueryUtil.js +45 -0
- package/build/dist/Server/Types/Database/QueryUtil.js.map +1 -1
- package/build/dist/Server/Utils/AI/AIChatPrivacyFilter.js +18 -0
- package/build/dist/Server/Utils/AI/AIChatPrivacyFilter.js.map +1 -0
- package/build/dist/Server/Utils/AI/AlertAIContextBuilder.js +6 -1
- package/build/dist/Server/Utils/AI/AlertAIContextBuilder.js.map +1 -1
- package/build/dist/Server/Utils/AI/Chat/ChatAgentRunner.js +756 -0
- package/build/dist/Server/Utils/AI/Chat/ChatAgentRunner.js.map +1 -0
- package/build/dist/Server/Utils/AI/Chat/ObservabilityAssistant.js +165 -0
- package/build/dist/Server/Utils/AI/Chat/ObservabilityAssistant.js.map +1 -0
- package/build/dist/Server/Utils/AI/Chat/ObservabilityChatPrompt.js +44 -0
- package/build/dist/Server/Utils/AI/Chat/ObservabilityChatPrompt.js.map +1 -0
- package/build/dist/Server/Utils/AI/IncidentAIContextBuilder.js +18 -3
- package/build/dist/Server/Utils/AI/IncidentAIContextBuilder.js.map +1 -1
- package/build/dist/Server/Utils/AI/IncidentEpisodeAIContextBuilder.js +6 -1
- package/build/dist/Server/Utils/AI/IncidentEpisodeAIContextBuilder.js.map +1 -1
- package/build/dist/Server/Utils/AI/ScheduledMaintenanceAIContextBuilder.js +12 -2
- package/build/dist/Server/Utils/AI/ScheduledMaintenanceAIContextBuilder.js.map +1 -1
- package/build/dist/Server/Utils/AI/Toolbox/AlertTools.js +167 -0
- package/build/dist/Server/Utils/AI/Toolbox/AlertTools.js.map +1 -0
- package/build/dist/Server/Utils/AI/Toolbox/AlertWriteTools.js +136 -0
- package/build/dist/Server/Utils/AI/Toolbox/AlertWriteTools.js.map +1 -0
- package/build/dist/Server/Utils/AI/Toolbox/ContextTools.js +141 -0
- package/build/dist/Server/Utils/AI/Toolbox/ContextTools.js.map +1 -0
- package/build/dist/Server/Utils/AI/Toolbox/ExceptionTools.js +117 -0
- package/build/dist/Server/Utils/AI/Toolbox/ExceptionTools.js.map +1 -0
- package/build/dist/Server/Utils/AI/Toolbox/IncidentTools.js +318 -0
- package/build/dist/Server/Utils/AI/Toolbox/IncidentTools.js.map +1 -0
- package/build/dist/Server/Utils/AI/Toolbox/IncidentWriteTools.js +280 -0
- package/build/dist/Server/Utils/AI/Toolbox/IncidentWriteTools.js.map +1 -0
- package/build/dist/Server/Utils/AI/Toolbox/Index.js +153 -0
- package/build/dist/Server/Utils/AI/Toolbox/Index.js.map +1 -0
- package/build/dist/Server/Utils/AI/Toolbox/LogTools.js +246 -0
- package/build/dist/Server/Utils/AI/Toolbox/LogTools.js.map +1 -0
- package/build/dist/Server/Utils/AI/Toolbox/MetricTools.js +120 -0
- package/build/dist/Server/Utils/AI/Toolbox/MetricTools.js.map +1 -0
- package/build/dist/Server/Utils/AI/Toolbox/MonitorTools.js +158 -0
- package/build/dist/Server/Utils/AI/Toolbox/MonitorTools.js.map +1 -0
- package/build/dist/Server/Utils/AI/Toolbox/RecentChangesTools.js +165 -0
- package/build/dist/Server/Utils/AI/Toolbox/RecentChangesTools.js.map +1 -0
- package/build/dist/Server/Utils/AI/Toolbox/Serializer.js +228 -0
- package/build/dist/Server/Utils/AI/Toolbox/Serializer.js.map +1 -0
- package/build/dist/Server/Utils/AI/Toolbox/ToolTypes.js +142 -0
- package/build/dist/Server/Utils/AI/Toolbox/ToolTypes.js.map +1 -0
- package/build/dist/Server/Utils/AI/Toolbox/TraceTools.js +309 -0
- package/build/dist/Server/Utils/AI/Toolbox/TraceTools.js.map +1 -0
- package/build/dist/Server/Utils/AI/Toolbox/WidgetBuilder.js +120 -0
- package/build/dist/Server/Utils/AI/Toolbox/WidgetBuilder.js.map +1 -0
- package/build/dist/Server/Utils/Database/MigrationFailureLog.js +174 -0
- package/build/dist/Server/Utils/Database/MigrationFailureLog.js.map +1 -0
- package/build/dist/Server/Utils/IncomingCallPhoneNumber.js +30 -0
- package/build/dist/Server/Utils/IncomingCallPhoneNumber.js.map +1 -0
- package/build/dist/Server/Utils/LLM/LLMService.js +452 -92
- package/build/dist/Server/Utils/LLM/LLMService.js.map +1 -1
- package/build/dist/Server/Utils/Telemetry/IoTSnapshotScan.js +11 -8
- package/build/dist/Server/Utils/Telemetry/IoTSnapshotScan.js.map +1 -1
- package/build/dist/Server/Utils/Telemetry/ProxmoxCephSnapshotScan.js +11 -8
- package/build/dist/Server/Utils/Telemetry/ProxmoxCephSnapshotScan.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js +378 -15
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/Slack/Slack.js +59 -0
- package/build/dist/Server/Utils/Workspace/Slack/Slack.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/Slack/app-manifest.json +16 -1
- package/build/dist/Types/AI/AIChatMessageRole.js +7 -0
- package/build/dist/Types/AI/AIChatMessageRole.js.map +1 -0
- package/build/dist/Types/AI/AIChatMessageStatus.js +27 -0
- package/build/dist/Types/AI/AIChatMessageStatus.js.map +1 -0
- package/build/dist/Types/AI/AIChatPermissionMode.js +53 -0
- package/build/dist/Types/AI/AIChatPermissionMode.js.map +1 -0
- package/build/dist/Types/AI/AIChatTypes.js +74 -0
- package/build/dist/Types/AI/AIChatTypes.js.map +1 -0
- package/build/dist/Types/AI/AIRunEventType.js +18 -0
- package/build/dist/Types/AI/AIRunEventType.js.map +1 -0
- package/build/dist/Types/AI/AIRunStatus.js +26 -0
- package/build/dist/Types/AI/AIRunStatus.js.map +1 -0
- package/build/dist/Types/AI/AIRunType.js +7 -0
- package/build/dist/Types/AI/AIRunType.js.map +1 -0
- package/build/dist/Types/Date.js +153 -15
- package/build/dist/Types/Date.js.map +1 -1
- package/build/dist/Types/LLM/LlmType.js +6 -0
- package/build/dist/Types/LLM/LlmType.js.map +1 -1
- package/build/dist/Types/OnCallDutyPolicy/Layer.js +602 -171
- package/build/dist/Types/OnCallDutyPolicy/Layer.js.map +1 -1
- package/build/dist/Types/OnCallDutyPolicy/RestrictionTimes.js +27 -13
- package/build/dist/Types/OnCallDutyPolicy/RestrictionTimes.js.map +1 -1
- package/build/dist/Types/OnCallDutyPolicy/UserOverrideUtil.js +20 -5
- package/build/dist/Types/OnCallDutyPolicy/UserOverrideUtil.js.map +1 -1
- package/build/dist/UI/Components/Events/RecurringFieldElement.js +13 -0
- package/build/dist/UI/Components/Events/RecurringFieldElement.js.map +1 -1
- package/build/dist/UI/Components/Header/HeaderIconDropdownButton.js +10 -5
- package/build/dist/UI/Components/Header/HeaderIconDropdownButton.js.map +1 -1
- package/build/dist/UI/Components/Markdown.tsx/MarkdownViewer.js +18 -4
- package/build/dist/UI/Components/Markdown.tsx/MarkdownViewer.js.map +1 -1
- package/build/dist/UI/Components/ModelFormModal/ModelFormModal.js.map +1 -1
- package/build/dist/UI/Components/Page/Page.js +3 -1
- package/build/dist/UI/Components/Page/Page.js.map +1 -1
- package/build/dist/UI/Components/RadioButtons/BasicRadioButtons.js +1 -1
- package/build/dist/UI/Components/RadioButtons/BasicRadioButtons.js.map +1 -1
- package/build/dist/UI/Utils/LlmTypeDropdownOptions.js +38 -0
- package/build/dist/UI/Utils/LlmTypeDropdownOptions.js.map +1 -0
- package/build/dist/UI/Utils/TestLLMProvider.js +37 -0
- package/build/dist/UI/Utils/TestLLMProvider.js.map +1 -0
- package/package.json +1 -1
|
@@ -23,6 +23,9 @@ import AlertEpisode from "../../Models/DatabaseModels/AlertEpisode";
|
|
|
23
23
|
import AlertEpisodeService from "./AlertEpisodeService";
|
|
24
24
|
import IncidentEpisode from "../../Models/DatabaseModels/IncidentEpisode";
|
|
25
25
|
import IncidentEpisodeService from "./IncidentEpisodeService";
|
|
26
|
+
import OneUptimeDate from "../../Types/Date";
|
|
27
|
+
import { JSONObject } from "../../Types/JSON";
|
|
28
|
+
import logger from "../Utils/Logger";
|
|
26
29
|
|
|
27
30
|
export class Service extends DatabaseService<Model> {
|
|
28
31
|
public constructor() {
|
|
@@ -32,6 +35,93 @@ export class Service extends DatabaseService<Model> {
|
|
|
32
35
|
}
|
|
33
36
|
}
|
|
34
37
|
|
|
38
|
+
/**
|
|
39
|
+
* Atomically claim the right to execute ONE notification rule for this on-call
|
|
40
|
+
* log. Overlapping UserOnCallLog:ExecutePendingExecutions runs (a tick that
|
|
41
|
+
* exceeds the 1-minute cadence, a stalled-job re-delivery, or a burst release
|
|
42
|
+
* across worker replicas) could both read executedNotificationRules without a
|
|
43
|
+
* given delayed rule's key, both write it, and both send — double-paging the
|
|
44
|
+
* responder for a single escalation (audit F7). This mirrors
|
|
45
|
+
* OnCallDutyPolicyExecutionLogService.claimEscalationAdvance: a single
|
|
46
|
+
* conditional UPDATE that sets executedNotificationRules[ruleId] only when the
|
|
47
|
+
* key is absent and RETURNs the affected row, so exactly one concurrent run
|
|
48
|
+
* wins and the loser skips.
|
|
49
|
+
*
|
|
50
|
+
* Fail-safe: if the atomic statement errors for any reason, fall back to the
|
|
51
|
+
* previous non-atomic read-modify-write so the rule is still marked and sent.
|
|
52
|
+
* For an on-call system a rare duplicate page (the pre-fix behavior) is far
|
|
53
|
+
* better than a missed page, so this never makes paging less reliable.
|
|
54
|
+
*
|
|
55
|
+
* Returns true when THIS call claimed the rule (caller should send), false when
|
|
56
|
+
* it was already executed/claimed (caller should skip) or the log is missing.
|
|
57
|
+
*/
|
|
58
|
+
@CaptureSpan()
|
|
59
|
+
public async claimNotificationRuleExecution(data: {
|
|
60
|
+
userOnCallLogId: ObjectID;
|
|
61
|
+
userNotificationRuleId: ObjectID;
|
|
62
|
+
}): Promise<boolean> {
|
|
63
|
+
const ruleKey: string = data.userNotificationRuleId.toString();
|
|
64
|
+
|
|
65
|
+
try {
|
|
66
|
+
const nowIso: string = OneUptimeDate.getCurrentDate().toISOString();
|
|
67
|
+
|
|
68
|
+
const rows: Array<{ _id: string }> =
|
|
69
|
+
await this.getRepository().manager.query(
|
|
70
|
+
`UPDATE "UserOnCallLog"
|
|
71
|
+
SET "executedNotificationRules" = jsonb_set(
|
|
72
|
+
COALESCE("executedNotificationRules", '{}')::jsonb,
|
|
73
|
+
ARRAY[$2::text],
|
|
74
|
+
to_jsonb($3::text),
|
|
75
|
+
true
|
|
76
|
+
)::json
|
|
77
|
+
WHERE "_id" = $1::uuid
|
|
78
|
+
AND NOT (COALESCE("executedNotificationRules", '{}')::jsonb ? $2::text)
|
|
79
|
+
RETURNING "_id"`,
|
|
80
|
+
[data.userOnCallLogId.toString(), ruleKey, nowIso],
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
return Array.isArray(rows) && rows.length > 0;
|
|
84
|
+
} catch (err) {
|
|
85
|
+
logger.error(
|
|
86
|
+
"claimNotificationRuleExecution atomic claim failed; falling back to non-atomic marking.",
|
|
87
|
+
);
|
|
88
|
+
logger.error(err);
|
|
89
|
+
|
|
90
|
+
// Fallback: previous non-atomic read-modify-write (reliable marking).
|
|
91
|
+
const log: Model | null = await this.findOneById({
|
|
92
|
+
id: data.userOnCallLogId,
|
|
93
|
+
props: { isRoot: true },
|
|
94
|
+
select: {
|
|
95
|
+
_id: true,
|
|
96
|
+
executedNotificationRules: true,
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
if (!log) {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const executed: JSONObject = log.executedNotificationRules || {};
|
|
105
|
+
|
|
106
|
+
if (Object.keys(executed).includes(ruleKey)) {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
executed[ruleKey] = OneUptimeDate.getCurrentDate();
|
|
111
|
+
|
|
112
|
+
await this.updateOneById({
|
|
113
|
+
id: log.id!,
|
|
114
|
+
data: {
|
|
115
|
+
executedNotificationRules: { ...executed },
|
|
116
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
117
|
+
} as any,
|
|
118
|
+
props: { isRoot: true },
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
35
125
|
@CaptureSpan()
|
|
36
126
|
protected override async onBeforeCreate(
|
|
37
127
|
createBy: CreateBy<Model>,
|
|
@@ -15,6 +15,8 @@ import UserNotificationExecutionStatus from "../../Types/UserNotification/UserNo
|
|
|
15
15
|
import User from "../../Models/DatabaseModels/User";
|
|
16
16
|
import Model from "../../Models/DatabaseModels/UserOnCallLogTimeline";
|
|
17
17
|
import AlertService from "./AlertService";
|
|
18
|
+
import AlertEpisodeService from "./AlertEpisodeService";
|
|
19
|
+
import IncidentEpisodeService from "./IncidentEpisodeService";
|
|
18
20
|
|
|
19
21
|
export class Service extends DatabaseService<Model> {
|
|
20
22
|
public constructor() {
|
|
@@ -40,6 +42,8 @@ export class Service extends DatabaseService<Model> {
|
|
|
40
42
|
onCallDutyPolicyExecutionLogId: true,
|
|
41
43
|
triggeredByIncidentId: true,
|
|
42
44
|
triggeredByAlertId: true,
|
|
45
|
+
triggeredByAlertEpisodeId: true,
|
|
46
|
+
triggeredByIncidentEpisodeId: true,
|
|
43
47
|
onCallDutyPolicyExecutionLogTimelineId: true,
|
|
44
48
|
},
|
|
45
49
|
skip: 0,
|
|
@@ -52,6 +56,19 @@ export class Service extends DatabaseService<Model> {
|
|
|
52
56
|
for (const item of items) {
|
|
53
57
|
const isIncident: boolean = Boolean(item.triggeredByIncidentId);
|
|
54
58
|
const isAlert: boolean = Boolean(item.triggeredByAlertId);
|
|
59
|
+
/*
|
|
60
|
+
* Alert-episode and incident-episode pages were never handled here, so
|
|
61
|
+
* acknowledging one via call/SMS/email/push marked only this user's log
|
|
62
|
+
* done but never acknowledged the EPISODE. ExecutePendingExecutions gates
|
|
63
|
+
* every co-notified user's continuation solely on isEpisodeAcknowledged,
|
|
64
|
+
* so the other responders kept escalating and the episode stayed
|
|
65
|
+
* unacknowledged in its own state (audit F15). Handle both episode kinds
|
|
66
|
+
* the same way incident/alert are handled below.
|
|
67
|
+
*/
|
|
68
|
+
const isAlertEpisode: boolean = Boolean(item.triggeredByAlertEpisodeId);
|
|
69
|
+
const isIncidentEpisode: boolean = Boolean(
|
|
70
|
+
item.triggeredByIncidentEpisodeId,
|
|
71
|
+
);
|
|
55
72
|
|
|
56
73
|
// this incident is acknowledged.
|
|
57
74
|
|
|
@@ -73,7 +90,16 @@ export class Service extends DatabaseService<Model> {
|
|
|
73
90
|
throw new BadDataException("User not found.");
|
|
74
91
|
}
|
|
75
92
|
|
|
76
|
-
const
|
|
93
|
+
const entityLabel: string =
|
|
94
|
+
isIncident || isIncidentEpisode
|
|
95
|
+
? isIncidentEpisode
|
|
96
|
+
? "Incident Episode"
|
|
97
|
+
: "Incident"
|
|
98
|
+
: isAlertEpisode
|
|
99
|
+
? "Alert Episode"
|
|
100
|
+
: "Alert";
|
|
101
|
+
|
|
102
|
+
const statusMessage: string = `${entityLabel} acknowledged by ${user.name} (${user.email})`;
|
|
77
103
|
|
|
78
104
|
await UserOnCallLogService.updateOneById({
|
|
79
105
|
id: item.userNotificationLogId!,
|
|
@@ -133,6 +159,22 @@ export class Service extends DatabaseService<Model> {
|
|
|
133
159
|
item.userId!,
|
|
134
160
|
);
|
|
135
161
|
}
|
|
162
|
+
|
|
163
|
+
if (isAlertEpisode) {
|
|
164
|
+
// alert episode — stops co-notified responders from escalating.
|
|
165
|
+
await AlertEpisodeService.acknowledgeEpisode(
|
|
166
|
+
item.triggeredByAlertEpisodeId!,
|
|
167
|
+
item.userId!,
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (isIncidentEpisode) {
|
|
172
|
+
// incident episode — stops co-notified responders from escalating.
|
|
173
|
+
await IncidentEpisodeService.acknowledgeEpisode(
|
|
174
|
+
item.triggeredByIncidentEpisodeId!,
|
|
175
|
+
item.userId!,
|
|
176
|
+
);
|
|
177
|
+
}
|
|
136
178
|
}
|
|
137
179
|
}
|
|
138
180
|
|
|
@@ -703,18 +703,31 @@ export default class ModelPermission {
|
|
|
703
703
|
* scale to telemetry volume; one Postgres roundtrip + one indexed
|
|
704
704
|
* predicate does. See Internal/Docs/PermissionsSimplification.md.
|
|
705
705
|
*/
|
|
706
|
-
|
|
706
|
+
/*
|
|
707
|
+
* Resolves the owned-scope decision for an analytics model without touching
|
|
708
|
+
* a query. Returns `null` when no ownership filter applies (root/master,
|
|
709
|
+
* creates, models without @OwnedThrough, no applicable permission rows, or
|
|
710
|
+
* an unrestricted grant) — i.e. the caller has full access. Otherwise
|
|
711
|
+
* returns the FK column plus the exact set of parent resource IDs the user
|
|
712
|
+
* may read (possibly empty, meaning "access to nothing").
|
|
713
|
+
*
|
|
714
|
+
* This is the single source of truth for owned-scope resolution:
|
|
715
|
+
* addOwnedScopeToQuery injects it into a ClickHouse query, and
|
|
716
|
+
* getAccessibleServiceIdsForAnalyticsModel exposes it to callers that build
|
|
717
|
+
* their own aggregation SQL (e.g. the AI toolbox), so the two can never
|
|
718
|
+
* drift apart.
|
|
719
|
+
*/
|
|
720
|
+
private static async resolveOwnedScope<TBaseModel extends BaseModel>(
|
|
707
721
|
modelType: { new (): TBaseModel },
|
|
708
|
-
query: Query<TBaseModel>,
|
|
709
722
|
props: DatabaseCommonInteractionProps,
|
|
710
723
|
type: DatabaseRequestType,
|
|
711
|
-
): Promise<
|
|
724
|
+
): Promise<{ fkColumn: string; allowedResourceIds: Set<string> } | null> {
|
|
712
725
|
if (props.isRoot || props.isMasterAdmin) {
|
|
713
|
-
return
|
|
726
|
+
return null;
|
|
714
727
|
}
|
|
715
728
|
|
|
716
729
|
if (type === DatabaseRequestType.Create) {
|
|
717
|
-
return
|
|
730
|
+
return null;
|
|
718
731
|
}
|
|
719
732
|
|
|
720
733
|
/*
|
|
@@ -725,7 +738,7 @@ export default class ModelPermission {
|
|
|
725
738
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
726
739
|
const model: any = new modelType();
|
|
727
740
|
if (!model.ownedThrough) {
|
|
728
|
-
return
|
|
741
|
+
return null;
|
|
729
742
|
}
|
|
730
743
|
|
|
731
744
|
const modelPermissions: Array<Permission> = this.getModelPermissions(
|
|
@@ -748,7 +761,7 @@ export default class ModelPermission {
|
|
|
748
761
|
);
|
|
749
762
|
|
|
750
763
|
if (applicableRows.length === 0) {
|
|
751
|
-
return
|
|
764
|
+
return null;
|
|
752
765
|
}
|
|
753
766
|
|
|
754
767
|
/*
|
|
@@ -771,7 +784,7 @@ export default class ModelPermission {
|
|
|
771
784
|
},
|
|
772
785
|
);
|
|
773
786
|
if (hasUnrestrictedGrant) {
|
|
774
|
-
return
|
|
787
|
+
return null;
|
|
775
788
|
}
|
|
776
789
|
|
|
777
790
|
const allowedResourceIds: Set<string> = new Set<string>();
|
|
@@ -831,7 +844,59 @@ export default class ModelPermission {
|
|
|
831
844
|
allowedResourceIds.add(props.tenantId.toString());
|
|
832
845
|
}
|
|
833
846
|
|
|
834
|
-
|
|
847
|
+
return { fkColumn: model.ownedThrough.fkColumn, allowedResourceIds };
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
/*
|
|
851
|
+
* The set of parent resource (Service) IDs the user may read for an analytics
|
|
852
|
+
* model, for callers that bypass findBy() and build aggregation SQL directly
|
|
853
|
+
* (e.g. the AI toolbox's log_histogram / query_traces, which call the
|
|
854
|
+
* aggregation services with a raw projectId). Pass the result as the
|
|
855
|
+
* aggregation's `serviceIds` filter.
|
|
856
|
+
*
|
|
857
|
+
* `null` means no ownership restriction applies — do NOT constrain (the user
|
|
858
|
+
* has project-wide access). A returned array (even empty) means the user is
|
|
859
|
+
* label/owned-restricted: constrain to exactly these IDs, and treat an empty
|
|
860
|
+
* array as "no accessible services" (match nothing), NEVER as "no filter".
|
|
861
|
+
*/
|
|
862
|
+
public static async getAccessibleServiceIdsForAnalyticsModel<
|
|
863
|
+
TBaseModel extends BaseModel,
|
|
864
|
+
>(
|
|
865
|
+
modelType: { new (): TBaseModel },
|
|
866
|
+
props: DatabaseCommonInteractionProps,
|
|
867
|
+
type: DatabaseRequestType,
|
|
868
|
+
): Promise<Array<ObjectID> | null> {
|
|
869
|
+
const scope: {
|
|
870
|
+
fkColumn: string;
|
|
871
|
+
allowedResourceIds: Set<string>;
|
|
872
|
+
} | null = await this.resolveOwnedScope(modelType, props, type);
|
|
873
|
+
|
|
874
|
+
if (!scope) {
|
|
875
|
+
return null;
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
return Array.from(scope.allowedResourceIds).map((id: string) => {
|
|
879
|
+
return new ObjectID(id);
|
|
880
|
+
});
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
private static async addOwnedScopeToQuery<TBaseModel extends BaseModel>(
|
|
884
|
+
modelType: { new (): TBaseModel },
|
|
885
|
+
query: Query<TBaseModel>,
|
|
886
|
+
props: DatabaseCommonInteractionProps,
|
|
887
|
+
type: DatabaseRequestType,
|
|
888
|
+
): Promise<Query<TBaseModel>> {
|
|
889
|
+
const scope: {
|
|
890
|
+
fkColumn: string;
|
|
891
|
+
allowedResourceIds: Set<string>;
|
|
892
|
+
} | null = await this.resolveOwnedScope(modelType, props, type);
|
|
893
|
+
|
|
894
|
+
if (!scope) {
|
|
895
|
+
return query;
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
const fkColumn: string = scope.fkColumn;
|
|
899
|
+
const allowedResourceIds: Set<string> = scope.allowedResourceIds;
|
|
835
900
|
const sentinelNoMatch: Array<string> = [
|
|
836
901
|
ObjectID.getZeroObjectID().toString(),
|
|
837
902
|
];
|
|
@@ -549,6 +549,63 @@ export default class QueryUtil {
|
|
|
549
549
|
_id: QueryHelper.any(query[key] as Array<string>),
|
|
550
550
|
};
|
|
551
551
|
}
|
|
552
|
+
|
|
553
|
+
/*
|
|
554
|
+
* Text-search operator nested under a single-Entity relation, e.g.
|
|
555
|
+
* { user: { name: new Search("foo") } }. serializeQuery otherwise only
|
|
556
|
+
* visits top-level keys, so the nested operator reaches TypeORM as a raw
|
|
557
|
+
* class instance and silently degrades to an exact equality
|
|
558
|
+
* (`user.name = 'foo'` instead of `user.name ILIKE '%foo%'`) — which is
|
|
559
|
+
* why the Owner / user picker "search" appeared to do nothing once a
|
|
560
|
+
* project had more than a page of members.
|
|
561
|
+
*
|
|
562
|
+
* We deliberately touch ONLY the ILIKE-family leaf operators here and
|
|
563
|
+
* leave every other nested value (arrays, ids, plain equality, other
|
|
564
|
+
* operators) exactly as it was, so existing nested relation filters (the
|
|
565
|
+
* access-control label filters built by @CanAccessIfCanReadOn, etc.)
|
|
566
|
+
* serialize unchanged.
|
|
567
|
+
*/
|
|
568
|
+
if (
|
|
569
|
+
tableColumnMetadata &&
|
|
570
|
+
tableColumnMetadata.modelType &&
|
|
571
|
+
tableColumnMetadata.type === TableColumnType.Entity &&
|
|
572
|
+
query[key] &&
|
|
573
|
+
typeof query[key] === Typeof.Object &&
|
|
574
|
+
!Array.isArray(query[key]) &&
|
|
575
|
+
(Object.getPrototypeOf(query[key]) === Object.prototype ||
|
|
576
|
+
Object.getPrototypeOf(query[key]) === null)
|
|
577
|
+
) {
|
|
578
|
+
const relationModel: BaseModel = new tableColumnMetadata.modelType();
|
|
579
|
+
const relationQuery: Record<string, any> = query[key] as Record<
|
|
580
|
+
string,
|
|
581
|
+
any
|
|
582
|
+
>;
|
|
583
|
+
for (const relationKey in relationQuery) {
|
|
584
|
+
const relationColumnMetadata: TableColumnMetadata =
|
|
585
|
+
relationModel.getTableColumnMetadata(relationKey);
|
|
586
|
+
if (!relationColumnMetadata) {
|
|
587
|
+
continue;
|
|
588
|
+
}
|
|
589
|
+
const nestedValue: any = relationQuery[relationKey];
|
|
590
|
+
if (nestedValue instanceof Search) {
|
|
591
|
+
relationQuery[relationKey] = QueryHelper.search(
|
|
592
|
+
(nestedValue as Search<string>).toString(),
|
|
593
|
+
) as any;
|
|
594
|
+
} else if (nestedValue instanceof StartsWith) {
|
|
595
|
+
relationQuery[relationKey] = QueryHelper.startsWith(
|
|
596
|
+
(nestedValue as StartsWith<string>).toString(),
|
|
597
|
+
) as any;
|
|
598
|
+
} else if (nestedValue instanceof EndsWith) {
|
|
599
|
+
relationQuery[relationKey] = QueryHelper.endsWith(
|
|
600
|
+
(nestedValue as EndsWith<string>).toString(),
|
|
601
|
+
) as any;
|
|
602
|
+
} else if (nestedValue instanceof NotContains) {
|
|
603
|
+
relationQuery[relationKey] = QueryHelper.notContains(
|
|
604
|
+
(nestedValue as NotContains<string>).toString(),
|
|
605
|
+
) as any;
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
}
|
|
552
609
|
}
|
|
553
610
|
|
|
554
611
|
return query;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import DatabaseCommonInteractionProps from "../../../Types/BaseDatabase/DatabaseCommonInteractionProps";
|
|
2
|
+
import NotAuthorizedException from "../../../Types/Exception/NotAuthorizedException";
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* AI conversations (and their messages, runs and run events) are personal to
|
|
6
|
+
* the user who created them. This filter pins every non-root query to the
|
|
7
|
+
* requesting user so one project member can never read another member's
|
|
8
|
+
* conversations — including through the auto-generated list/count endpoints.
|
|
9
|
+
*/
|
|
10
|
+
export function pinQueryToRequestingUser<TQuery>(
|
|
11
|
+
query: TQuery,
|
|
12
|
+
props: DatabaseCommonInteractionProps,
|
|
13
|
+
userColumnName: string,
|
|
14
|
+
): TQuery {
|
|
15
|
+
if (props.isRoot || props.isMasterAdmin) {
|
|
16
|
+
return query;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (!props.userId) {
|
|
20
|
+
throw new NotAuthorizedException(
|
|
21
|
+
"AI conversations are personal and can only be accessed by the user who created them.",
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
(query as Record<string, unknown>)[userColumnName] = props.userId;
|
|
26
|
+
|
|
27
|
+
return query;
|
|
28
|
+
}
|
|
@@ -235,7 +235,12 @@ The note should:
|
|
|
235
235
|
4. Be detailed enough to help team members understand the situation
|
|
236
236
|
5. Use technical language appropriate for the engineering team
|
|
237
237
|
|
|
238
|
-
Write in markdown format for better readability. Be thorough and technical
|
|
238
|
+
Write in markdown format for better readability. Be thorough and technical.
|
|
239
|
+
|
|
240
|
+
Grounding rules (important):
|
|
241
|
+
- Use ONLY facts that appear in the provided alert data. Do NOT invent causes, metrics, impact, or actions the data does not support.
|
|
242
|
+
- If something a section needs is not in the data, write "Not available in the alert record" instead of guessing.
|
|
243
|
+
- Never fabricate numbers or state confidence levels.`;
|
|
239
244
|
}
|
|
240
245
|
|
|
241
246
|
// Build user message
|