@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
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import ToolResultSerializer, {
|
|
2
|
+
SerializedResult,
|
|
3
|
+
} from "../../../../Server/Utils/AI/Toolbox/Serializer";
|
|
4
|
+
import { JSONObject } from "../../../../Types/JSON";
|
|
5
|
+
import { describe, expect, test } from "@jest/globals";
|
|
6
|
+
|
|
7
|
+
describe("ToolResultSerializer.redact", () => {
|
|
8
|
+
test("redacts email addresses", () => {
|
|
9
|
+
const result: { text: string; count: number } = ToolResultSerializer.redact(
|
|
10
|
+
"user john.doe@example.com logged in",
|
|
11
|
+
);
|
|
12
|
+
expect(result.text).toBe("user [redacted-email] logged in");
|
|
13
|
+
expect(result.count).toBe(1);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
test("redacts JWTs", () => {
|
|
17
|
+
const jwt: string = `eyJhbGciOiJIUzI1NiJ9.${"a".repeat(20)}.${"b".repeat(10)}`;
|
|
18
|
+
const result: { text: string; count: number } = ToolResultSerializer.redact(
|
|
19
|
+
`token=${jwt} used`,
|
|
20
|
+
);
|
|
21
|
+
expect(result.text).toContain("[redacted-jwt]");
|
|
22
|
+
expect(result.text).not.toContain(jwt);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test("redacts bearer tokens", () => {
|
|
26
|
+
const result: { text: string; count: number } = ToolResultSerializer.redact(
|
|
27
|
+
"Authorization: Bearer abcdefghijklmnop1234567890",
|
|
28
|
+
);
|
|
29
|
+
expect(result.text).not.toContain("abcdefghijklmnop1234567890");
|
|
30
|
+
expect(result.text).toContain("[redacted");
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test("redacts IPv4 addresses", () => {
|
|
34
|
+
const result: { text: string; count: number } = ToolResultSerializer.redact(
|
|
35
|
+
"request from 203.0.113.42 failed",
|
|
36
|
+
);
|
|
37
|
+
expect(result.text).toBe("request from [redacted-ip] failed");
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test("redacts long hex strings", () => {
|
|
41
|
+
const hex: string = "deadbeef".repeat(5);
|
|
42
|
+
const result: { text: string; count: number } = ToolResultSerializer.redact(
|
|
43
|
+
`session ${hex} expired`,
|
|
44
|
+
);
|
|
45
|
+
expect(result.text).toContain("[redacted-hex]");
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test("preserves 32-char OTel trace IDs and 16-char span IDs", () => {
|
|
49
|
+
/*
|
|
50
|
+
* Exactly 32 hex = W3C/OTel trace ID; exactly 16 hex = span ID. Both must
|
|
51
|
+
* survive so the model can pivot search_logs -> get_trace.
|
|
52
|
+
*/
|
|
53
|
+
const traceId: string = "4bf92f3577b34da6a3ce929d0e0e4736";
|
|
54
|
+
const spanId: string = "00f067aa0ba902b7";
|
|
55
|
+
const result: { text: string; count: number } = ToolResultSerializer.redact(
|
|
56
|
+
`traceId=${traceId} spanId=${spanId}`,
|
|
57
|
+
);
|
|
58
|
+
expect(result.text).toContain(traceId);
|
|
59
|
+
expect(result.text).toContain(spanId);
|
|
60
|
+
expect(result.text).not.toContain("[redacted-hex]");
|
|
61
|
+
expect(result.count).toBe(0);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test("still redacts hex secrets longer than a trace ID (33+ chars)", () => {
|
|
65
|
+
const sha256: string = "a".repeat(64);
|
|
66
|
+
const result: { text: string; count: number } = ToolResultSerializer.redact(
|
|
67
|
+
`digest ${sha256} verified`,
|
|
68
|
+
);
|
|
69
|
+
expect(result.text).toContain("[redacted-hex]");
|
|
70
|
+
expect(result.text).not.toContain(sha256);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test("redacts key=value secrets and keeps the key via capture groups", () => {
|
|
74
|
+
const result: { text: string; count: number } = ToolResultSerializer.redact(
|
|
75
|
+
"config: password=supersecretvalue retries=3",
|
|
76
|
+
);
|
|
77
|
+
expect(result.text).toContain("password=[redacted]");
|
|
78
|
+
expect(result.text).not.toContain("supersecretvalue");
|
|
79
|
+
expect(result.text).toContain("retries=3");
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
test("leaves benign text untouched", () => {
|
|
83
|
+
const text: string = "p95 latency is 230ms for checkout";
|
|
84
|
+
const result: { text: string; count: number } =
|
|
85
|
+
ToolResultSerializer.redact(text);
|
|
86
|
+
expect(result.text).toBe(text);
|
|
87
|
+
expect(result.count).toBe(0);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
describe("ToolResultSerializer.serializeRows", () => {
|
|
92
|
+
test("caps rows at 50 and marks truncation", () => {
|
|
93
|
+
const rows: Array<JSONObject> = [];
|
|
94
|
+
for (let i: number = 0; i < 80; i++) {
|
|
95
|
+
rows.push({ index: i, value: `row-${i}` });
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const result: SerializedResult = ToolResultSerializer.serializeRows(rows);
|
|
99
|
+
expect(result.isTruncated).toBe(true);
|
|
100
|
+
expect(result.rowCount).toBe(80);
|
|
101
|
+
expect(result.text.split("\n").length).toBeLessThanOrEqual(51);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
test("tells the model how many rows were hidden when capped", () => {
|
|
105
|
+
const rows: Array<JSONObject> = [];
|
|
106
|
+
for (let i: number = 0; i < 80; i++) {
|
|
107
|
+
rows.push({ index: i, value: `row-${i}` });
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const result: SerializedResult = ToolResultSerializer.serializeRows(rows);
|
|
111
|
+
expect(result.text).toContain("first 50 of 80 rows");
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test("does not add a truncation marker when rows fit", () => {
|
|
115
|
+
const rows: Array<JSONObject> = [{ index: 1 }, { index: 2 }];
|
|
116
|
+
const result: SerializedResult = ToolResultSerializer.serializeRows(rows);
|
|
117
|
+
expect(result.isTruncated).toBe(false);
|
|
118
|
+
expect(result.text).not.toContain("showing the first");
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
test("truncates long field values", () => {
|
|
122
|
+
const result: SerializedResult = ToolResultSerializer.serializeRows([
|
|
123
|
+
{ body: "x".repeat(2000) },
|
|
124
|
+
]);
|
|
125
|
+
expect(result.isTruncated).toBe(true);
|
|
126
|
+
expect(result.text).toContain("[truncated]");
|
|
127
|
+
expect(result.text.length).toBeLessThan(700);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
test("caps total payload size", () => {
|
|
131
|
+
const rows: Array<JSONObject> = [];
|
|
132
|
+
for (let i: number = 0; i < 50; i++) {
|
|
133
|
+
rows.push({ body: "y".repeat(490) });
|
|
134
|
+
}
|
|
135
|
+
const result: SerializedResult = ToolResultSerializer.serializeRows(rows);
|
|
136
|
+
expect(Buffer.byteLength(result.text, "utf8")).toBeLessThanOrEqual(
|
|
137
|
+
17 * 1024,
|
|
138
|
+
);
|
|
139
|
+
expect(result.isTruncated).toBe(true);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
test("reports zero rows honestly", () => {
|
|
143
|
+
const result: SerializedResult = ToolResultSerializer.serializeRows([]);
|
|
144
|
+
expect(result.rowCount).toBe(0);
|
|
145
|
+
expect(result.text).toBe("(no rows found)");
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
test("redacts inside rows", () => {
|
|
149
|
+
const result: SerializedResult = ToolResultSerializer.serializeRows([
|
|
150
|
+
{ body: "contact admin@corp.com now" },
|
|
151
|
+
]);
|
|
152
|
+
expect(result.text).toContain("[redacted-email]");
|
|
153
|
+
expect(result.redactionCount).toBe(1);
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
describe("ToolResultSerializer.redact — additional credential formats", () => {
|
|
158
|
+
test("redacts PEM private key blocks", () => {
|
|
159
|
+
const key: string = `-----BEGIN RSA PRIVATE KEY-----
|
|
160
|
+
MIIBOgIBAAJBAKj34GkxFhD90vcNLYLInFEX6Ppy1tPf9Cnzj4p4WGeKLs1Pt8Qu
|
|
161
|
+
KUpRKfFLfRYC9AIKjbJTWit+CqvjWYzvQwECAwEAAQ==
|
|
162
|
+
-----END RSA PRIVATE KEY-----`;
|
|
163
|
+
const result: { text: string; count: number } = ToolResultSerializer.redact(
|
|
164
|
+
`key:\n${key}`,
|
|
165
|
+
);
|
|
166
|
+
expect(result.text).toContain("[redacted-private-key]");
|
|
167
|
+
expect(result.text).not.toContain("MIIBOgIBAAJBAKj34");
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
test("redacts AWS access key ids", () => {
|
|
171
|
+
const result: { text: string; count: number } = ToolResultSerializer.redact(
|
|
172
|
+
"aws_key=AKIAIOSFODNN7EXAMPLE region=us-east-1",
|
|
173
|
+
);
|
|
174
|
+
expect(result.text).toContain("[redacted-aws-key]");
|
|
175
|
+
expect(result.text).not.toContain("AKIAIOSFODNN7EXAMPLE");
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
test("redacts GitHub tokens", () => {
|
|
179
|
+
const token: string = `ghp_${"a".repeat(36)}`;
|
|
180
|
+
const result: { text: string; count: number } = ToolResultSerializer.redact(
|
|
181
|
+
`remote https://${token}@github.com/x/y`,
|
|
182
|
+
);
|
|
183
|
+
expect(result.text).toContain("[redacted-github-token]");
|
|
184
|
+
expect(result.text).not.toContain(token);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
test("redacts Slack tokens", () => {
|
|
188
|
+
const result: { text: string; count: number } = ToolResultSerializer.redact(
|
|
189
|
+
"SLACK_TOKEN=xoxb-1234567890-abcdefghijklmnop",
|
|
190
|
+
);
|
|
191
|
+
expect(result.text).toContain("[redacted-slack-token]");
|
|
192
|
+
expect(result.text).not.toContain("xoxb-1234567890-abcdefghijklmnop");
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
test("redacts Google API keys", () => {
|
|
196
|
+
const apiKey: string = `AIza${"a".repeat(35)}`;
|
|
197
|
+
const result: { text: string; count: number } = ToolResultSerializer.redact(
|
|
198
|
+
`key=${apiKey}`,
|
|
199
|
+
);
|
|
200
|
+
expect(result.text).toContain("[redacted-google-api-key]");
|
|
201
|
+
expect(result.text).not.toContain(apiKey);
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
test("redacts grouped payment card numbers", () => {
|
|
205
|
+
const result: { text: string; count: number } = ToolResultSerializer.redact(
|
|
206
|
+
"charge 4111 1111 1111 1111 ok",
|
|
207
|
+
);
|
|
208
|
+
expect(result.text).toContain("[redacted-card]");
|
|
209
|
+
expect(result.text).not.toContain("4111 1111 1111 1111");
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
test("does not redact a bare 16-digit number (span-id collision guard)", () => {
|
|
213
|
+
/*
|
|
214
|
+
* An all-numeric 16-char span id must survive; only the space/dash-grouped
|
|
215
|
+
* card form is redacted, so a bare 16-digit run stays intact.
|
|
216
|
+
*/
|
|
217
|
+
const numeric: string = "1234567890123456";
|
|
218
|
+
const result: { text: string; count: number } = ToolResultSerializer.redact(
|
|
219
|
+
`value=${numeric}`,
|
|
220
|
+
);
|
|
221
|
+
expect(result.text).toContain(numeric);
|
|
222
|
+
});
|
|
223
|
+
});
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import SubscriptionStatus, {
|
|
2
|
+
SubscriptionStatusUtil,
|
|
3
|
+
} from "../../../Types/Billing/SubscriptionStatus";
|
|
4
|
+
|
|
5
|
+
describe("SubscriptionStatusUtil", () => {
|
|
6
|
+
describe("isSubscriptionActive", () => {
|
|
7
|
+
test("treats a missing status as active", () => {
|
|
8
|
+
expect(SubscriptionStatusUtil.isSubscriptionActive(undefined)).toBe(true);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test.each([
|
|
12
|
+
SubscriptionStatus.Active,
|
|
13
|
+
SubscriptionStatus.Trialing,
|
|
14
|
+
SubscriptionStatus.PastDue,
|
|
15
|
+
])("returns true for %s", (status: SubscriptionStatus) => {
|
|
16
|
+
expect(SubscriptionStatusUtil.isSubscriptionActive(status)).toBe(true);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test.each([
|
|
20
|
+
SubscriptionStatus.Incomplete,
|
|
21
|
+
SubscriptionStatus.IncompleteExpired,
|
|
22
|
+
SubscriptionStatus.Canceled,
|
|
23
|
+
SubscriptionStatus.Unpaid,
|
|
24
|
+
SubscriptionStatus.Expired,
|
|
25
|
+
SubscriptionStatus.Paused,
|
|
26
|
+
])("returns false for %s", (status: SubscriptionStatus) => {
|
|
27
|
+
expect(SubscriptionStatusUtil.isSubscriptionActive(status)).toBe(false);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
describe("isSubscriptionInactive", () => {
|
|
32
|
+
test("is the inverse of isSubscriptionActive", () => {
|
|
33
|
+
const statuses: Array<SubscriptionStatus | undefined> = [
|
|
34
|
+
undefined,
|
|
35
|
+
...Object.values(SubscriptionStatus),
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
for (const status of statuses) {
|
|
39
|
+
expect(SubscriptionStatusUtil.isSubscriptionInactive(status)).toBe(
|
|
40
|
+
!SubscriptionStatusUtil.isSubscriptionActive(status),
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test("treats a missing status as active (not inactive)", () => {
|
|
46
|
+
expect(SubscriptionStatusUtil.isSubscriptionInactive(undefined)).toBe(
|
|
47
|
+
false,
|
|
48
|
+
);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
describe("isSubscriptionOverdue", () => {
|
|
53
|
+
test("returns false for a missing status", () => {
|
|
54
|
+
expect(SubscriptionStatusUtil.isSubscriptionOverdue(undefined)).toBe(
|
|
55
|
+
false,
|
|
56
|
+
);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test("returns true only for PastDue", () => {
|
|
60
|
+
expect(
|
|
61
|
+
SubscriptionStatusUtil.isSubscriptionOverdue(
|
|
62
|
+
SubscriptionStatus.PastDue,
|
|
63
|
+
),
|
|
64
|
+
).toBe(true);
|
|
65
|
+
expect(
|
|
66
|
+
SubscriptionStatusUtil.isSubscriptionOverdue(SubscriptionStatus.Active),
|
|
67
|
+
).toBe(false);
|
|
68
|
+
expect(
|
|
69
|
+
SubscriptionStatusUtil.isSubscriptionOverdue(
|
|
70
|
+
SubscriptionStatus.Canceled,
|
|
71
|
+
),
|
|
72
|
+
).toBe(false);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
describe("isSubscriptionCancelled", () => {
|
|
77
|
+
test("returns false for a missing status", () => {
|
|
78
|
+
expect(SubscriptionStatusUtil.isSubscriptionCancelled(undefined)).toBe(
|
|
79
|
+
false,
|
|
80
|
+
);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test.each([
|
|
84
|
+
SubscriptionStatus.Canceled,
|
|
85
|
+
SubscriptionStatus.Unpaid,
|
|
86
|
+
SubscriptionStatus.Expired,
|
|
87
|
+
SubscriptionStatus.IncompleteExpired,
|
|
88
|
+
])("returns true for %s", (status: SubscriptionStatus) => {
|
|
89
|
+
expect(SubscriptionStatusUtil.isSubscriptionCancelled(status)).toBe(true);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test.each([
|
|
93
|
+
SubscriptionStatus.Active,
|
|
94
|
+
SubscriptionStatus.Trialing,
|
|
95
|
+
SubscriptionStatus.PastDue,
|
|
96
|
+
SubscriptionStatus.Incomplete,
|
|
97
|
+
SubscriptionStatus.Paused,
|
|
98
|
+
])("returns false for %s", (status: SubscriptionStatus) => {
|
|
99
|
+
expect(SubscriptionStatusUtil.isSubscriptionCancelled(status)).toBe(
|
|
100
|
+
false,
|
|
101
|
+
);
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
describe("status relationships", () => {
|
|
106
|
+
test("PastDue is both active and overdue", () => {
|
|
107
|
+
expect(
|
|
108
|
+
SubscriptionStatusUtil.isSubscriptionActive(SubscriptionStatus.PastDue),
|
|
109
|
+
).toBe(true);
|
|
110
|
+
expect(
|
|
111
|
+
SubscriptionStatusUtil.isSubscriptionOverdue(
|
|
112
|
+
SubscriptionStatus.PastDue,
|
|
113
|
+
),
|
|
114
|
+
).toBe(true);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
test("active and cancelled statuses never overlap", () => {
|
|
118
|
+
for (const status of Object.values(SubscriptionStatus)) {
|
|
119
|
+
const active: boolean =
|
|
120
|
+
SubscriptionStatusUtil.isSubscriptionActive(status);
|
|
121
|
+
const cancelled: boolean =
|
|
122
|
+
SubscriptionStatusUtil.isSubscriptionCancelled(status);
|
|
123
|
+
expect(active && cancelled).toBe(false);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
});
|