@oneuptime/common 12.0.13 → 12.0.14
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/OnCallDutyPolicySchedule.ts +14 -0
- package/Models/DatabaseModels/UserCall.ts +94 -3
- package/Models/DatabaseModels/UserEmail.ts +94 -3
- package/Models/DatabaseModels/UserIncomingCallNumber.ts +94 -3
- package/Models/DatabaseModels/UserPush.ts +37 -0
- package/Models/DatabaseModels/UserSMS.ts +94 -3
- package/Models/DatabaseModels/UserWhatsApp.ts +93 -2
- package/Server/API/BaseAPI.ts +79 -14
- package/Server/API/UserCallAPI.ts +53 -45
- package/Server/API/UserEmailAPI.ts +53 -44
- package/Server/API/UserIncomingCallNumberAPI.ts +48 -38
- package/Server/API/UserNotificationMethodAdminAPI.ts +481 -0
- package/Server/API/UserPushAPI.ts +126 -2
- package/Server/API/UserSmsAPI.ts +53 -44
- package/Server/API/UserWhatsAppAPI.ts +53 -50
- package/Server/Infrastructure/Postgres/SchemaMigrations/1787142779538-MigrationName.ts +154 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1787156982416-MigrationName.ts +17 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1787700000000-FixTotpOtpUrlAlgorithm.ts +45 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +6 -0
- package/Server/Middleware/VerificationCodeRateLimit.ts +586 -0
- package/Server/Services/AnalyticsDatabaseService.ts +169 -0
- package/Server/Services/DatabaseService.ts +101 -0
- package/Server/Services/LogAggregationService.ts +5 -0
- package/Server/Services/PushNotificationService.ts +127 -12
- package/Server/Services/TeamMemberService.ts +53 -13
- package/Server/Services/UserCallService.ts +55 -24
- package/Server/Services/UserEmailService.ts +83 -17
- package/Server/Services/UserIncomingCallNumberService.ts +49 -85
- package/Server/Services/UserNotificationMethodAdminService.ts +1527 -0
- package/Server/Services/UserNotificationRuleService.ts +26 -0
- package/Server/Services/UserPushService.ts +89 -0
- package/Server/Services/UserSmsService.ts +50 -17
- package/Server/Services/UserWhatsAppService.ts +48 -15
- package/Server/Types/Database/QueryHelper.ts +30 -0
- package/Server/Utils/AnalyticsDatabase/QuerySettingsHelper.ts +59 -0
- package/Server/Utils/ChannelVerification.ts +510 -0
- package/Server/Utils/Monitor/Criteria/IncomingRequestCriteria.ts +13 -16
- package/Server/Utils/Monitor/MonitorAlert.ts +24 -21
- package/Server/Utils/Monitor/MonitorIncident.ts +21 -18
- package/Server/Utils/Monitor/MonitorResourceContext.ts +107 -0
- package/Server/Utils/Monitor/MonitorStepResourceIdentity.ts +442 -0
- package/Server/Utils/Monitor/SeriesResourceLabels.ts +3 -3
- package/Server/Utils/Monitor/SeriesResourceLinker.ts +96 -28
- package/Server/Utils/TotpAuth.ts +137 -9
- package/Server/Utils/UserRegistrationToken.ts +182 -0
- package/Server/Utils/VerificationCode.ts +134 -0
- package/Tests/App/Dashboard/AdminNotificationRulesPage.test.tsx +173 -94
- package/Tests/App/Dashboard/AdminUserNotificationMethodsPage.test.tsx +1151 -0
- package/Tests/App/Dashboard/AdminUserOnCallPages.test.tsx +905 -0
- package/Tests/App/Dashboard/DashboardCommandPalette.test.tsx +338 -0
- package/Tests/App/Dashboard/InvestigationPanel.test.tsx +1 -1
- package/Tests/App/Dashboard/MonitorTypePicker.test.tsx +28 -0
- package/Tests/Models/UserPushCriticalAlertColumn.test.ts +172 -0
- package/Tests/Server/API/BaseAPIGetListParallel.test.ts +519 -0
- package/Tests/Server/API/NotificationChannelVerificationAPI.test.ts +543 -0
- package/Tests/Server/API/UserIncomingCallNumberApi.test.ts +108 -18
- package/Tests/Server/API/UserNotificationMethodAdminAPI.test.ts +963 -0
- package/Tests/Server/API/UserPushCriticalAlertsApi.test.ts +114 -0
- package/Tests/Server/API/UserSmsApi.test.ts +107 -14
- package/Tests/Server/API/UserTotpAuthAPI.test.ts +427 -0
- package/Tests/Server/Infrastructure/Postgres/FixTotpOtpUrlAlgorithmMigration.test.ts +315 -0
- package/Tests/Server/Middleware/VerificationCodeRateLimit.test.ts +775 -0
- package/Tests/Server/Services/AddNetworkDeviceReachabilityColumnsMigration.test.ts +10 -62
- package/Tests/Server/Services/AnalyticsDatabasePaginationStability.test.ts +33 -13
- package/Tests/Server/Services/AnalyticsDatabaseSortKeyBoundary.test.ts +658 -0
- package/Tests/Server/Services/CriticalOnCallAlertDelivery.test.ts +458 -0
- package/Tests/Server/Services/CriticalPushAlertPayload.test.ts +301 -0
- package/Tests/Server/Services/DatabaseServiceAtomicIncrement.test.ts +143 -0
- package/Tests/Server/Services/DeliverNotificationForRuleExtraction.test.ts +1 -0
- package/Tests/Server/Services/LogAggregationScanMemory.test.ts +421 -0
- package/Tests/Server/Services/LogAggregationService.test.ts +2 -2
- package/Tests/Server/Services/NotificationChannelCodeIssuance.test.ts +401 -0
- package/Tests/Server/Services/PushNotificationDeliveryOptions.test.ts +204 -0
- package/Tests/Server/Services/TeamMemberAutoAcceptInvitation.test.ts +21 -1
- package/Tests/Server/Services/TeamMemberInviteRegistrationToken.test.ts +290 -0
- package/Tests/Server/Services/UserNotificationMethodAdminService.test.ts +948 -0
- package/Tests/Server/Services/UserNotificationRuleExecuteItem.test.ts +1 -0
- package/Tests/Server/Services/UserPushCriticalAlertToggle.test.ts +255 -0
- package/Tests/Server/Services/UserTotpAuthEnrolment.test.ts +218 -0
- package/Tests/Server/TestingUtils/AuthenticatorApp.ts +248 -0
- package/Tests/Server/Types/Database/Permissions/NotificationChannelVerificationColumns.test.ts +135 -0
- package/Tests/Server/Types/Database/Permissions/OnCallScheduleRelationSelect.test.ts +504 -0
- package/Tests/Server/Types/Database/QueryHelperFindWithSameTextAnyOf.test.ts +91 -0
- package/Tests/Server/Types/Workflow/Components/JsonToText.test.ts +384 -0
- package/Tests/Server/Types/Workflow/Components/MergeJson.test.ts +403 -0
- package/Tests/Server/Utils/Browser.test.ts +162 -0
- package/Tests/Server/Utils/ChannelVerification.test.ts +689 -0
- package/Tests/Server/Utils/Express.test.ts +371 -0
- package/Tests/Server/Utils/Monitor/Criteria/CustomCodeMonitorCriteria.test.ts +707 -0
- package/Tests/Server/Utils/Monitor/Criteria/DnsMonitorCriteria.test.ts +698 -0
- package/Tests/Server/Utils/Monitor/Criteria/IncomingEmailBodyCriteria.test.ts +243 -0
- package/Tests/Server/Utils/Monitor/Criteria/IncomingRequestBodyCriteria.test.ts +278 -0
- package/Tests/Server/Utils/Monitor/MonitorAlertResourceLinking.test.ts +160 -20
- package/Tests/Server/Utils/Monitor/MonitorDependencySuppressionCreatorSkip.test.ts +13 -8
- package/Tests/Server/Utils/Monitor/MonitorIncidentResourceLinking.test.ts +162 -18
- package/Tests/Server/Utils/Monitor/MonitorResourceContext.test.ts +349 -0
- package/Tests/Server/Utils/Monitor/MonitorStepResourceIdentity.test.ts +690 -0
- package/Tests/Server/Utils/Monitor/MonitorSummaryPersistence.test.ts +7 -2
- package/Tests/Server/Utils/Monitor/SeriesResourceLinker.test.ts +92 -18
- package/Tests/Server/Utils/PushNotificationUtilCreators.test.ts +267 -0
- package/Tests/Server/Utils/Telemetry/OneuptimeLabel.test.ts +439 -0
- package/Tests/Server/Utils/TotpAuth.test.ts +719 -0
- package/Tests/Server/Utils/UserRegistrationToken.test.ts +322 -0
- package/Tests/Server/Utils/VerificationCode.test.ts +296 -0
- package/Tests/Types/AutoRemediation/AutoRemediationSuggestionStatus.test.ts +192 -0
- package/Tests/Types/Call/CallRequest.test.ts +189 -0
- package/Tests/Types/Dashboard/DashboardSize.test.ts +226 -0
- package/Tests/Types/Incident/IncidentSlaStatus.test.ts +191 -0
- package/Tests/Types/Metrics/MetricDashboardMetricType.test.ts +278 -0
- package/Tests/Types/Metrics/MetricPipelineRuleType.test.ts +517 -0
- package/Tests/Types/Monitor/IncomingMonitorDefaultCriteria.test.ts +470 -0
- package/Tests/Types/Monitor/MonitorCriteriaInstance.test.ts +6 -4
- package/Tests/Types/Monitor/Recommendation/MonitorRecommendationCatalog.test.ts +262 -5
- package/Tests/Types/Monitor/Recommendation/MonitorRecommendationCoverage.test.ts +1 -1
- package/Tests/Types/Monitor/Recommendation/MonitorRecommendationNotificationMode.test.ts +1 -1
- package/Tests/Types/Monitor/ServiceAlertTemplates.test.ts +905 -0
- package/Tests/Types/Service/ServiceLanguage.test.ts +255 -0
- package/Tests/Types/TextRandomGeneration.test.ts +211 -0
- package/Tests/UI/Components/Button.test.tsx +175 -1
- package/Tests/UI/Components/CodeBlockLanguages.test.tsx +236 -0
- package/Tests/UI/Components/CommandPalette/CommandPalette.test.tsx +568 -0
- package/Tests/UI/Components/CommandPalette/CommandPaletteKeyboard.test.tsx +239 -0
- package/Tests/UI/Components/CommandPalette/CommandPaletteProviders.test.tsx +400 -0
- package/Tests/UI/Components/CommandPalette/PaletteFilter.test.ts +234 -0
- package/Tests/UI/Components/CommandPalette/RecentCommands.test.ts +97 -0
- package/Tests/UI/Components/CountModelSideMenuItemGuard.test.tsx +198 -0
- package/Tests/UI/Components/FeedItemSafeMode.test.tsx +1 -1
- package/Tests/UI/Components/Forms/Utils/FormFieldSchemaTypeUtil.test.ts +267 -0
- package/Tests/UI/Components/List.test.tsx +9 -2
- package/Tests/UI/Components/ListLoadingStates.test.tsx +173 -0
- package/Tests/UI/Components/MarkdownLazy.test.tsx +113 -0
- package/Tests/UI/Components/MarkdownMermaidRetry.test.tsx +110 -0
- package/Tests/UI/Components/ModelTable/useCustomFieldColumns.test.tsx +8 -0
- package/Tests/UI/Components/MonitorTemplateVariables/TemplateVariablesCatalog.test.ts +692 -0
- package/Tests/UI/Components/MoreMenuMotion.test.tsx +118 -0
- package/Tests/UI/Components/NavBarCommandKGating.test.tsx +178 -0
- package/Tests/UI/Components/OrderedStatesList.test.tsx +19 -2
- package/Tests/UI/Components/SideOverMotion.test.tsx +109 -0
- package/Tests/UI/Components/Skeleton.test.tsx +71 -0
- package/Tests/UI/Components/TableLoadingStates.test.tsx +279 -0
- package/Tests/UI/Components/Tabs.test.tsx +24 -0
- package/Tests/UI/Components/Toast.test.tsx +130 -7
- package/Tests/UI/Components/ToastStacking.test.tsx +198 -0
- package/Tests/UI/Utils/Dropdown.test.ts +423 -0
- package/Tests/UI/Utils/ModelAPITenantHeader.test.ts +122 -0
- package/Tests/UI/Utils/ModelListCache.test.ts +338 -0
- package/Tests/UI/Utils/ProjectListCacheInvalidation.test.ts +225 -0
- package/Tests/Utils/API.test.ts +16 -2
- package/Tests/Utils/Dashboard/Components/DashboardKubernetesResourceListShared.test.ts +347 -0
- package/Tests/Utils/Dashboard/Components/DashboardListSharedArgs.test.ts +259 -0
- package/Tests/Utils/Dashboard/Components/DashboardMonitorListComponent.test.ts +466 -0
- package/Tests/Utils/Rum/UrlScrubberSegments.test.ts +362 -0
- package/Types/Email/EmailTemplateType.ts +1 -0
- package/Types/Monitor/MonitorCriteriaInstance.ts +41 -20
- package/Types/Monitor/Recommendation/MonitorRecommendationCatalog.ts +131 -8
- package/Types/Monitor/Recommendation/MonitorRecommendationTypes.ts +48 -8
- package/Types/Monitor/ServiceAlertTemplates.ts +1352 -0
- package/Types/Permission.ts +35 -0
- package/Types/PushNotification/AndroidNotificationChannel.ts +26 -0
- package/Types/PushNotification/PushNotificationMessage.ts +15 -0
- package/Types/PushNotification/PushNotificationRequest.ts +8 -16
- package/Types/Service/ServiceLanguage.ts +144 -0
- package/Types/Text.ts +111 -19
- package/UI/Components/Button/Button.tsx +27 -14
- package/UI/Components/CodeBlock/CodeBlock.tsx +54 -7
- package/UI/Components/CodeBlock/LanguageRegistry.ts +103 -0
- package/UI/Components/CommandPalette/CommandPalette.tsx +790 -0
- package/UI/Components/CommandPalette/PaletteFilter.ts +196 -0
- package/UI/Components/CommandPalette/PaletteRow.tsx +173 -0
- package/UI/Components/CommandPalette/RecentCommands.ts +57 -0
- package/UI/Components/CommandPalette/Types.ts +49 -0
- package/UI/Components/CommandPalette/UseProviderSearch.ts +129 -0
- package/UI/Components/Dropdown/Dropdown.tsx +6 -1
- package/UI/Components/Feed/FeedItem.tsx +1 -1
- package/UI/Components/List/List.tsx +37 -5
- package/UI/Components/List/ListSkeleton.tsx +54 -0
- package/UI/Components/Markdown.tsx/LazyMarkdownViewer.tsx +6 -1
- package/UI/Components/Markdown.tsx/MarkdownViewer.tsx +71 -26
- package/UI/Components/Modal/Modal.tsx +2 -2
- package/UI/Components/ModelTable/BaseModelTable.tsx +1 -1
- package/UI/Components/ModelTable/useCustomFieldColumns.ts +11 -5
- package/UI/Components/MoreMenu/MoreMenu.tsx +39 -1
- package/UI/Components/Navbar/NavBar.tsx +14 -1
- package/UI/Components/OrderedStatesList/OrderedStatesList.tsx +50 -5
- package/UI/Components/SideMenu/CountModelSideMenuItem.tsx +40 -1
- package/UI/Components/SideOver/SideOver.tsx +37 -2
- package/UI/Components/Skeleton/Skeleton.tsx +53 -0
- package/UI/Components/Table/Table.tsx +74 -44
- package/UI/Components/Table/TableSkeletonRows.tsx +141 -0
- package/UI/Components/Tabs/Tab.tsx +1 -1
- package/UI/Components/Toast/Toast.tsx +118 -53
- package/UI/Components/Toast/ToastInit.tsx +82 -32
- package/UI/Styles/Theme.css +40 -0
- package/UI/Utils/ModelAPI/ModelAPI.ts +20 -10
- package/UI/Utils/ModelListCache.ts +188 -0
- package/UI/Utils/Project.ts +29 -0
- package/Utils/API.ts +6 -1
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicySchedule.js +14 -0
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicySchedule.js.map +1 -1
- package/build/dist/Models/DatabaseModels/UserCall.js +101 -3
- package/build/dist/Models/DatabaseModels/UserCall.js.map +1 -1
- package/build/dist/Models/DatabaseModels/UserEmail.js +101 -3
- package/build/dist/Models/DatabaseModels/UserEmail.js.map +1 -1
- package/build/dist/Models/DatabaseModels/UserIncomingCallNumber.js +101 -3
- package/build/dist/Models/DatabaseModels/UserIncomingCallNumber.js.map +1 -1
- package/build/dist/Models/DatabaseModels/UserPush.js +38 -0
- package/build/dist/Models/DatabaseModels/UserPush.js.map +1 -1
- package/build/dist/Models/DatabaseModels/UserSMS.js +101 -3
- package/build/dist/Models/DatabaseModels/UserSMS.js.map +1 -1
- package/build/dist/Models/DatabaseModels/UserWhatsApp.js +100 -2
- package/build/dist/Models/DatabaseModels/UserWhatsApp.js.map +1 -1
- package/build/dist/Server/API/BaseAPI.js +69 -13
- package/build/dist/Server/API/BaseAPI.js.map +1 -1
- package/build/dist/Server/API/UserCallAPI.js +42 -38
- package/build/dist/Server/API/UserCallAPI.js.map +1 -1
- package/build/dist/Server/API/UserEmailAPI.js +42 -38
- package/build/dist/Server/API/UserEmailAPI.js.map +1 -1
- package/build/dist/Server/API/UserIncomingCallNumberAPI.js +37 -32
- package/build/dist/Server/API/UserIncomingCallNumberAPI.js.map +1 -1
- package/build/dist/Server/API/UserNotificationMethodAdminAPI.js +341 -0
- package/build/dist/Server/API/UserNotificationMethodAdminAPI.js.map +1 -0
- package/build/dist/Server/API/UserPushAPI.js +95 -2
- package/build/dist/Server/API/UserPushAPI.js.map +1 -1
- package/build/dist/Server/API/UserSmsAPI.js +42 -38
- package/build/dist/Server/API/UserSmsAPI.js.map +1 -1
- package/build/dist/Server/API/UserWhatsAppAPI.js +42 -40
- package/build/dist/Server/API/UserWhatsAppAPI.js.map +1 -1
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1787142779538-MigrationName.js +89 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1787142779538-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1787156982416-MigrationName.js +12 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1787156982416-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1787700000000-FixTotpOtpUrlAlgorithm.js +40 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1787700000000-FixTotpOtpUrlAlgorithm.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +6 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Middleware/VerificationCodeRateLimit.js +393 -0
- package/build/dist/Server/Middleware/VerificationCodeRateLimit.js.map +1 -0
- package/build/dist/Server/Services/AnalyticsDatabaseService.js +136 -0
- package/build/dist/Server/Services/AnalyticsDatabaseService.js.map +1 -1
- package/build/dist/Server/Services/DatabaseService.js +74 -0
- package/build/dist/Server/Services/DatabaseService.js.map +1 -1
- package/build/dist/Server/Services/LogAggregationService.js +5 -0
- package/build/dist/Server/Services/LogAggregationService.js.map +1 -1
- package/build/dist/Server/Services/PushNotificationService.js +69 -30
- package/build/dist/Server/Services/PushNotificationService.js.map +1 -1
- package/build/dist/Server/Services/TeamMemberService.js +43 -7
- package/build/dist/Server/Services/TeamMemberService.js.map +1 -1
- package/build/dist/Server/Services/UserCallService.js +54 -22
- package/build/dist/Server/Services/UserCallService.js.map +1 -1
- package/build/dist/Server/Services/UserEmailService.js +78 -17
- package/build/dist/Server/Services/UserEmailService.js.map +1 -1
- package/build/dist/Server/Services/UserIncomingCallNumberService.js +45 -74
- package/build/dist/Server/Services/UserIncomingCallNumberService.js.map +1 -1
- package/build/dist/Server/Services/UserNotificationMethodAdminService.js +1117 -0
- package/build/dist/Server/Services/UserNotificationMethodAdminService.js.map +1 -0
- package/build/dist/Server/Services/UserNotificationRuleService.js +20 -0
- package/build/dist/Server/Services/UserNotificationRuleService.js.map +1 -1
- package/build/dist/Server/Services/UserPushService.js +77 -0
- package/build/dist/Server/Services/UserPushService.js.map +1 -1
- package/build/dist/Server/Services/UserSmsService.js +50 -17
- package/build/dist/Server/Services/UserSmsService.js.map +1 -1
- package/build/dist/Server/Services/UserWhatsAppService.js +48 -15
- package/build/dist/Server/Services/UserWhatsAppService.js.map +1 -1
- package/build/dist/Server/Types/Database/QueryHelper.js +27 -0
- package/build/dist/Server/Types/Database/QueryHelper.js.map +1 -1
- package/build/dist/Server/Utils/AnalyticsDatabase/QuerySettingsHelper.js +46 -0
- package/build/dist/Server/Utils/AnalyticsDatabase/QuerySettingsHelper.js.map +1 -1
- package/build/dist/Server/Utils/ChannelVerification.js +348 -0
- package/build/dist/Server/Utils/ChannelVerification.js.map +1 -0
- package/build/dist/Server/Utils/Monitor/Criteria/IncomingRequestCriteria.js +13 -12
- package/build/dist/Server/Utils/Monitor/Criteria/IncomingRequestCriteria.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorAlert.js +20 -17
- package/build/dist/Server/Utils/Monitor/MonitorAlert.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorIncident.js +17 -14
- package/build/dist/Server/Utils/Monitor/MonitorIncident.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorResourceContext.js +95 -0
- package/build/dist/Server/Utils/Monitor/MonitorResourceContext.js.map +1 -0
- package/build/dist/Server/Utils/Monitor/MonitorStepResourceIdentity.js +313 -0
- package/build/dist/Server/Utils/Monitor/MonitorStepResourceIdentity.js.map +1 -0
- package/build/dist/Server/Utils/Monitor/SeriesResourceLabels.js +3 -3
- package/build/dist/Server/Utils/Monitor/SeriesResourceLinker.js +67 -26
- package/build/dist/Server/Utils/Monitor/SeriesResourceLinker.js.map +1 -1
- package/build/dist/Server/Utils/TotpAuth.js +127 -8
- package/build/dist/Server/Utils/TotpAuth.js.map +1 -1
- package/build/dist/Server/Utils/UserRegistrationToken.js +170 -0
- package/build/dist/Server/Utils/UserRegistrationToken.js.map +1 -0
- package/build/dist/Server/Utils/VerificationCode.js +120 -0
- package/build/dist/Server/Utils/VerificationCode.js.map +1 -0
- package/build/dist/Types/Email/EmailTemplateType.js +1 -0
- package/build/dist/Types/Email/EmailTemplateType.js.map +1 -1
- package/build/dist/Types/Monitor/MonitorCriteriaInstance.js +42 -21
- package/build/dist/Types/Monitor/MonitorCriteriaInstance.js.map +1 -1
- package/build/dist/Types/Monitor/Recommendation/MonitorRecommendationCatalog.js +77 -5
- package/build/dist/Types/Monitor/Recommendation/MonitorRecommendationCatalog.js.map +1 -1
- package/build/dist/Types/Monitor/Recommendation/MonitorRecommendationTypes.js +18 -6
- package/build/dist/Types/Monitor/Recommendation/MonitorRecommendationTypes.js.map +1 -1
- package/build/dist/Types/Monitor/ServiceAlertTemplates.js +1028 -0
- package/build/dist/Types/Monitor/ServiceAlertTemplates.js.map +1 -0
- package/build/dist/Types/Permission.js +33 -0
- package/build/dist/Types/Permission.js.map +1 -1
- package/build/dist/Types/PushNotification/AndroidNotificationChannel.js +27 -0
- package/build/dist/Types/PushNotification/AndroidNotificationChannel.js.map +1 -0
- package/build/dist/Types/Service/ServiceLanguage.js +96 -0
- package/build/dist/Types/Service/ServiceLanguage.js.map +1 -0
- package/build/dist/Types/Text.js +82 -17
- package/build/dist/Types/Text.js.map +1 -1
- package/build/dist/UI/Components/Button/Button.js +22 -14
- package/build/dist/UI/Components/Button/Button.js.map +1 -1
- package/build/dist/UI/Components/CodeBlock/CodeBlock.js +35 -3
- package/build/dist/UI/Components/CodeBlock/CodeBlock.js.map +1 -1
- package/build/dist/UI/Components/CodeBlock/LanguageRegistry.js +57 -0
- package/build/dist/UI/Components/CodeBlock/LanguageRegistry.js.map +1 -0
- package/build/dist/UI/Components/CommandPalette/CommandPalette.js +439 -0
- package/build/dist/UI/Components/CommandPalette/CommandPalette.js.map +1 -0
- package/build/dist/UI/Components/CommandPalette/PaletteFilter.js +135 -0
- package/build/dist/UI/Components/CommandPalette/PaletteFilter.js.map +1 -0
- package/build/dist/UI/Components/CommandPalette/PaletteRow.js +83 -0
- package/build/dist/UI/Components/CommandPalette/PaletteRow.js.map +1 -0
- package/build/dist/UI/Components/CommandPalette/RecentCommands.js +47 -0
- package/build/dist/UI/Components/CommandPalette/RecentCommands.js.map +1 -0
- package/build/dist/UI/Components/CommandPalette/Types.js +2 -0
- package/build/dist/UI/Components/CommandPalette/Types.js.map +1 -0
- package/build/dist/UI/Components/CommandPalette/UseProviderSearch.js +88 -0
- package/build/dist/UI/Components/CommandPalette/UseProviderSearch.js.map +1 -0
- package/build/dist/UI/Components/Dropdown/Dropdown.js +6 -1
- package/build/dist/UI/Components/Dropdown/Dropdown.js.map +1 -1
- package/build/dist/UI/Components/Feed/FeedItem.js +1 -1
- package/build/dist/UI/Components/Feed/FeedItem.js.map +1 -1
- package/build/dist/UI/Components/List/List.js +19 -5
- package/build/dist/UI/Components/List/List.js.map +1 -1
- package/build/dist/UI/Components/List/ListSkeleton.js +21 -0
- package/build/dist/UI/Components/List/ListSkeleton.js.map +1 -0
- package/build/dist/UI/Components/Markdown.tsx/LazyMarkdownViewer.js.map +1 -1
- package/build/dist/UI/Components/Markdown.tsx/MarkdownViewer.js +52 -25
- package/build/dist/UI/Components/Markdown.tsx/MarkdownViewer.js.map +1 -1
- package/build/dist/UI/Components/Modal/Modal.js +2 -2
- package/build/dist/UI/Components/ModelTable/BaseModelTable.js +1 -1
- package/build/dist/UI/Components/ModelTable/BaseModelTable.js.map +1 -1
- package/build/dist/UI/Components/ModelTable/useCustomFieldColumns.js +9 -2
- package/build/dist/UI/Components/ModelTable/useCustomFieldColumns.js.map +1 -1
- package/build/dist/UI/Components/MoreMenu/MoreMenu.js +32 -1
- package/build/dist/UI/Components/MoreMenu/MoreMenu.js.map +1 -1
- package/build/dist/UI/Components/Navbar/NavBar.js +5 -1
- package/build/dist/UI/Components/Navbar/NavBar.js.map +1 -1
- package/build/dist/UI/Components/OrderedStatesList/OrderedStatesList.js +29 -5
- package/build/dist/UI/Components/OrderedStatesList/OrderedStatesList.js.map +1 -1
- package/build/dist/UI/Components/SideMenu/CountModelSideMenuItem.js +23 -1
- package/build/dist/UI/Components/SideMenu/CountModelSideMenuItem.js.map +1 -1
- package/build/dist/UI/Components/SideOver/SideOver.js +23 -2
- package/build/dist/UI/Components/SideOver/SideOver.js.map +1 -1
- package/build/dist/UI/Components/Skeleton/Skeleton.js +23 -0
- package/build/dist/UI/Components/Skeleton/Skeleton.js.map +1 -0
- package/build/dist/UI/Components/Table/Table.js +35 -24
- package/build/dist/UI/Components/Table/Table.js.map +1 -1
- package/build/dist/UI/Components/Table/TableSkeletonRows.js +52 -0
- package/build/dist/UI/Components/Table/TableSkeletonRows.js.map +1 -0
- package/build/dist/UI/Components/Tabs/Tab.js +1 -1
- package/build/dist/UI/Components/Tabs/Tab.js.map +1 -1
- package/build/dist/UI/Components/Toast/Toast.js +77 -23
- package/build/dist/UI/Components/Toast/Toast.js.map +1 -1
- package/build/dist/UI/Components/Toast/ToastInit.js +37 -15
- package/build/dist/UI/Components/Toast/ToastInit.js.map +1 -1
- package/build/dist/UI/Utils/ModelAPI/ModelAPI.js +18 -9
- package/build/dist/UI/Utils/ModelAPI/ModelAPI.js.map +1 -1
- package/build/dist/UI/Utils/ModelListCache.js +126 -0
- package/build/dist/UI/Utils/ModelListCache.js.map +1 -0
- package/build/dist/UI/Utils/Project.js +24 -1
- package/build/dist/UI/Utils/Project.js.map +1 -1
- package/build/dist/Utils/API.js +6 -1
- package/build/dist/Utils/API.js.map +1 -1
- package/jest.config.json +1 -1
- package/package.json +2 -3
- package/Server/Utils/Monitor/MonitorClusterContext.ts +0 -182
- package/Tests/__mocks__/otpauth.js +0 -30
- package/build/dist/Server/Utils/Monitor/MonitorClusterContext.js +0 -141
- package/build/dist/Server/Utils/Monitor/MonitorClusterContext.js.map +0 -1
|
@@ -0,0 +1,517 @@
|
|
|
1
|
+
import MetricPipelineRuleType from "../../../Types/Metrics/MetricPipelineRuleType";
|
|
2
|
+
import { describe, expect, test } from "@jest/globals";
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* MetricPipelineRuleType is a string-backed enum whose values are persisted
|
|
6
|
+
* (MetricPipelineRule.ruleType) and used as the dispatch key in the metric
|
|
7
|
+
* ingest pipeline. The string values are therefore load-bearing: renaming a
|
|
8
|
+
* value silently breaks every already-stored rule. These tests pin the value
|
|
9
|
+
* contract, the completeness of the member set, and the documented per-value
|
|
10
|
+
* behaviour via a small pure dispatcher that mirrors the ingest semantics.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/* The exact, order-independent set the enum is expected to expose. */
|
|
14
|
+
const EXPECTED_VALUES: Record<string, string> = {
|
|
15
|
+
Filter: "Filter",
|
|
16
|
+
Drop: "Drop",
|
|
17
|
+
RenameMetric: "RenameMetric",
|
|
18
|
+
RenameAttribute: "RenameAttribute",
|
|
19
|
+
AddAttribute: "AddAttribute",
|
|
20
|
+
RemoveAttribute: "RemoveAttribute",
|
|
21
|
+
RedactAttribute: "RedactAttribute",
|
|
22
|
+
Sample: "Sample",
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
describe("MetricPipelineRuleType", () => {
|
|
26
|
+
describe("value contract", () => {
|
|
27
|
+
test("each member serializes to its exact documented string", () => {
|
|
28
|
+
expect(MetricPipelineRuleType.Filter).toBe("Filter");
|
|
29
|
+
expect(MetricPipelineRuleType.Drop).toBe("Drop");
|
|
30
|
+
expect(MetricPipelineRuleType.RenameMetric).toBe("RenameMetric");
|
|
31
|
+
expect(MetricPipelineRuleType.RenameAttribute).toBe("RenameAttribute");
|
|
32
|
+
expect(MetricPipelineRuleType.AddAttribute).toBe("AddAttribute");
|
|
33
|
+
expect(MetricPipelineRuleType.RemoveAttribute).toBe("RemoveAttribute");
|
|
34
|
+
expect(MetricPipelineRuleType.RedactAttribute).toBe("RedactAttribute");
|
|
35
|
+
expect(MetricPipelineRuleType.Sample).toBe("Sample");
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test("every member is a non-empty string (safe as a DB column value)", () => {
|
|
39
|
+
const values: Array<MetricPipelineRuleType> = Object.values(
|
|
40
|
+
MetricPipelineRuleType,
|
|
41
|
+
);
|
|
42
|
+
for (const value of values) {
|
|
43
|
+
expect(typeof value).toBe("string");
|
|
44
|
+
expect(value.length).toBeGreaterThan(0);
|
|
45
|
+
/* No stray whitespace that would corrupt an equality-based lookup. */
|
|
46
|
+
expect(value).toBe(value.trim());
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
describe("member set completeness", () => {
|
|
52
|
+
test("exposes exactly the expected members, no more and no fewer", () => {
|
|
53
|
+
/*
|
|
54
|
+
* A string enum has no reverse (numeric) mapping, so Object.values and
|
|
55
|
+
* Object.keys each yield precisely the declared members.
|
|
56
|
+
*/
|
|
57
|
+
expect([...Object.values(MetricPipelineRuleType)].sort()).toEqual(
|
|
58
|
+
[...Object.values(EXPECTED_VALUES)].sort(),
|
|
59
|
+
);
|
|
60
|
+
expect([...Object.keys(MetricPipelineRuleType)].sort()).toEqual(
|
|
61
|
+
[...Object.keys(EXPECTED_VALUES)].sort(),
|
|
62
|
+
);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test("has the documented cardinality of eight rule types", () => {
|
|
66
|
+
expect(Object.values(MetricPipelineRuleType)).toHaveLength(8);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test("the key equals the value for every member", () => {
|
|
70
|
+
const entries: Array<[string, string]> = Object.entries(
|
|
71
|
+
MetricPipelineRuleType,
|
|
72
|
+
);
|
|
73
|
+
for (const [key, value] of entries) {
|
|
74
|
+
expect(key).toBe(value);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test("all values are unique (no aliasing to the same string)", () => {
|
|
79
|
+
const values: Array<MetricPipelineRuleType> = Object.values(
|
|
80
|
+
MetricPipelineRuleType,
|
|
81
|
+
);
|
|
82
|
+
expect(new Set(values).size).toBe(values.length);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
describe("persistence round-trip", () => {
|
|
87
|
+
test("a member survives JSON serialize/parse unchanged", () => {
|
|
88
|
+
const original: MetricPipelineRuleType =
|
|
89
|
+
MetricPipelineRuleType.RedactAttribute;
|
|
90
|
+
const restored: MetricPipelineRuleType = JSON.parse(
|
|
91
|
+
JSON.stringify(original),
|
|
92
|
+
) as MetricPipelineRuleType;
|
|
93
|
+
|
|
94
|
+
expect(restored).toBe(original);
|
|
95
|
+
expect(restored).toBe(MetricPipelineRuleType.RedactAttribute);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
test("a persisted string casts back to the matching enum member", () => {
|
|
99
|
+
/* Simulates reading rule.ruleType back out of the database as a string. */
|
|
100
|
+
for (const value of Object.values(MetricPipelineRuleType)) {
|
|
101
|
+
const persisted: string = value as string;
|
|
102
|
+
const rehydrated: MetricPipelineRuleType =
|
|
103
|
+
persisted as MetricPipelineRuleType;
|
|
104
|
+
expect(rehydrated).toBe(value);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
test("an unrelated string does not collide with any member", () => {
|
|
109
|
+
const values: Array<string> = Object.values(MetricPipelineRuleType);
|
|
110
|
+
expect(values).not.toContain("filter");
|
|
111
|
+
expect(values).not.toContain("SampleRate");
|
|
112
|
+
expect(values).not.toContain("");
|
|
113
|
+
expect(values).not.toContain("Unknown");
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
describe("exhaustive Record keying (UI metadata / switch maps)", () => {
|
|
118
|
+
test("supports a total Record keyed by every member", () => {
|
|
119
|
+
/*
|
|
120
|
+
* The dashboard builds a metadata map keyed by MetricPipelineRuleType.
|
|
121
|
+
* A total Record must resolve for every member and only for members.
|
|
122
|
+
*/
|
|
123
|
+
const labels: Record<MetricPipelineRuleType, string> = {
|
|
124
|
+
[MetricPipelineRuleType.Filter]: "Filter",
|
|
125
|
+
[MetricPipelineRuleType.Drop]: "Drop",
|
|
126
|
+
[MetricPipelineRuleType.RenameMetric]: "Rename metric",
|
|
127
|
+
[MetricPipelineRuleType.RenameAttribute]: "Rename attribute",
|
|
128
|
+
[MetricPipelineRuleType.AddAttribute]: "Add attribute",
|
|
129
|
+
[MetricPipelineRuleType.RemoveAttribute]: "Remove attribute",
|
|
130
|
+
[MetricPipelineRuleType.RedactAttribute]: "Redact attribute",
|
|
131
|
+
[MetricPipelineRuleType.Sample]: "Sample",
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
for (const value of Object.values(MetricPipelineRuleType)) {
|
|
135
|
+
expect(labels[value]).toBeDefined();
|
|
136
|
+
expect(labels[value].length).toBeGreaterThan(0);
|
|
137
|
+
}
|
|
138
|
+
expect(Object.keys(labels)).toHaveLength(
|
|
139
|
+
Object.values(MetricPipelineRuleType).length,
|
|
140
|
+
);
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
/*
|
|
146
|
+
* Pure dispatcher mirroring OtelMetricsIngestService.applyRule() branch
|
|
147
|
+
* structure, keyed entirely on MetricPipelineRuleType. It exercises each enum
|
|
148
|
+
* value, the Filter allowlist precedence, the non-matching short-circuit, and
|
|
149
|
+
* the default (unknown value) path. Kept deterministic: Sample is decided by a
|
|
150
|
+
* caller-supplied roll instead of Math.random so there is no wall-clock or RNG
|
|
151
|
+
* dependency.
|
|
152
|
+
*/
|
|
153
|
+
|
|
154
|
+
interface FakeRow {
|
|
155
|
+
name: string;
|
|
156
|
+
attributes: Record<string, string>;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
interface ApplyOptions {
|
|
160
|
+
matched: boolean;
|
|
161
|
+
renameMetricTo?: string;
|
|
162
|
+
renameFromKey?: string;
|
|
163
|
+
renameToKey?: string;
|
|
164
|
+
attributeKey?: string;
|
|
165
|
+
attributeValue?: string;
|
|
166
|
+
redactReplacement?: string;
|
|
167
|
+
samplePercentage?: number;
|
|
168
|
+
/* Deterministic stand-in for Math.random() * 100, in the range [0, 100). */
|
|
169
|
+
sampleRoll?: number;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
interface ApplyResult {
|
|
173
|
+
row: FakeRow | null;
|
|
174
|
+
hitDefault: boolean;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function applyRule(
|
|
178
|
+
ruleType: MetricPipelineRuleType,
|
|
179
|
+
row: FakeRow,
|
|
180
|
+
options: ApplyOptions,
|
|
181
|
+
): ApplyResult {
|
|
182
|
+
const matched: boolean = options.matched;
|
|
183
|
+
|
|
184
|
+
/* Filter is an allowlist and is decided before the non-matching gate. */
|
|
185
|
+
if (ruleType === MetricPipelineRuleType.Filter) {
|
|
186
|
+
return { row: matched ? row : null, hitDefault: false };
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/* All other rule types are no-ops for rows they do not match. */
|
|
190
|
+
if (!matched) {
|
|
191
|
+
return { row, hitDefault: false };
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
switch (ruleType) {
|
|
195
|
+
case MetricPipelineRuleType.Drop:
|
|
196
|
+
return { row: null, hitDefault: false };
|
|
197
|
+
|
|
198
|
+
case MetricPipelineRuleType.Sample: {
|
|
199
|
+
const pct: number =
|
|
200
|
+
typeof options.samplePercentage === "number"
|
|
201
|
+
? options.samplePercentage
|
|
202
|
+
: 100;
|
|
203
|
+
const roll: number =
|
|
204
|
+
typeof options.sampleRoll === "number" ? options.sampleRoll : 0;
|
|
205
|
+
return { row: roll >= pct ? null : row, hitDefault: false };
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
case MetricPipelineRuleType.RenameMetric: {
|
|
209
|
+
if (options.renameMetricTo) {
|
|
210
|
+
row.name = options.renameMetricTo;
|
|
211
|
+
}
|
|
212
|
+
return { row, hitDefault: false };
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
case MetricPipelineRuleType.RenameAttribute: {
|
|
216
|
+
const from: string | undefined = options.renameFromKey || undefined;
|
|
217
|
+
const to: string | undefined = options.renameToKey || undefined;
|
|
218
|
+
if (
|
|
219
|
+
from &&
|
|
220
|
+
to &&
|
|
221
|
+
Object.prototype.hasOwnProperty.call(row.attributes, from)
|
|
222
|
+
) {
|
|
223
|
+
row.attributes[to] = row.attributes[from] as string;
|
|
224
|
+
delete row.attributes[from];
|
|
225
|
+
}
|
|
226
|
+
return { row, hitDefault: false };
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
case MetricPipelineRuleType.AddAttribute: {
|
|
230
|
+
const key: string | undefined = options.attributeKey || undefined;
|
|
231
|
+
if (key) {
|
|
232
|
+
row.attributes[key] = options.attributeValue ?? "";
|
|
233
|
+
}
|
|
234
|
+
return { row, hitDefault: false };
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
case MetricPipelineRuleType.RemoveAttribute: {
|
|
238
|
+
const key: string | undefined = options.attributeKey || undefined;
|
|
239
|
+
if (key && Object.prototype.hasOwnProperty.call(row.attributes, key)) {
|
|
240
|
+
delete row.attributes[key];
|
|
241
|
+
}
|
|
242
|
+
return { row, hitDefault: false };
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
case MetricPipelineRuleType.RedactAttribute: {
|
|
246
|
+
const key: string | undefined = options.attributeKey || undefined;
|
|
247
|
+
if (key && Object.prototype.hasOwnProperty.call(row.attributes, key)) {
|
|
248
|
+
row.attributes[key] = options.redactReplacement || "[REDACTED]";
|
|
249
|
+
}
|
|
250
|
+
return { row, hitDefault: false };
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
default:
|
|
254
|
+
/* An unknown / future value keeps the row untouched, like the service. */
|
|
255
|
+
return { row, hitDefault: true };
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function makeRow(): FakeRow {
|
|
260
|
+
return {
|
|
261
|
+
name: "http_requests_total",
|
|
262
|
+
attributes: { host: "a", env: "prod" },
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
describe("MetricPipelineRuleType dispatch semantics", () => {
|
|
267
|
+
describe("Filter (allowlist precedence)", () => {
|
|
268
|
+
test("keeps a matching row", () => {
|
|
269
|
+
const result: ApplyResult = applyRule(
|
|
270
|
+
MetricPipelineRuleType.Filter,
|
|
271
|
+
makeRow(),
|
|
272
|
+
{ matched: true },
|
|
273
|
+
);
|
|
274
|
+
expect(result.row).not.toBeNull();
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
test("drops a non-matching row (opposite of every other type)", () => {
|
|
278
|
+
const result: ApplyResult = applyRule(
|
|
279
|
+
MetricPipelineRuleType.Filter,
|
|
280
|
+
makeRow(),
|
|
281
|
+
{ matched: false },
|
|
282
|
+
);
|
|
283
|
+
expect(result.row).toBeNull();
|
|
284
|
+
});
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
describe("non-matching short-circuit for non-Filter types", () => {
|
|
288
|
+
test.each([
|
|
289
|
+
MetricPipelineRuleType.Drop,
|
|
290
|
+
MetricPipelineRuleType.RenameMetric,
|
|
291
|
+
MetricPipelineRuleType.RenameAttribute,
|
|
292
|
+
MetricPipelineRuleType.AddAttribute,
|
|
293
|
+
MetricPipelineRuleType.RemoveAttribute,
|
|
294
|
+
MetricPipelineRuleType.RedactAttribute,
|
|
295
|
+
MetricPipelineRuleType.Sample,
|
|
296
|
+
])(
|
|
297
|
+
"%s leaves a non-matching row untouched",
|
|
298
|
+
(ruleType: MetricPipelineRuleType) => {
|
|
299
|
+
const row: FakeRow = makeRow();
|
|
300
|
+
const result: ApplyResult = applyRule(ruleType, row, {
|
|
301
|
+
matched: false,
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
expect(result.row).toBe(row);
|
|
305
|
+
expect(result.hitDefault).toBe(false);
|
|
306
|
+
/* Unchanged: name and attributes exactly as seeded. */
|
|
307
|
+
expect(row.name).toBe("http_requests_total");
|
|
308
|
+
expect(row.attributes).toEqual({ host: "a", env: "prod" });
|
|
309
|
+
},
|
|
310
|
+
);
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
describe("Drop", () => {
|
|
314
|
+
test("drops a matching row", () => {
|
|
315
|
+
const result: ApplyResult = applyRule(
|
|
316
|
+
MetricPipelineRuleType.Drop,
|
|
317
|
+
makeRow(),
|
|
318
|
+
{ matched: true },
|
|
319
|
+
);
|
|
320
|
+
expect(result.row).toBeNull();
|
|
321
|
+
});
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
describe("Sample (deterministic boundary behaviour)", () => {
|
|
325
|
+
test("a roll below the percentage keeps the row", () => {
|
|
326
|
+
const result: ApplyResult = applyRule(
|
|
327
|
+
MetricPipelineRuleType.Sample,
|
|
328
|
+
makeRow(),
|
|
329
|
+
{ matched: true, samplePercentage: 50, sampleRoll: 49.9 },
|
|
330
|
+
);
|
|
331
|
+
expect(result.row).not.toBeNull();
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
test("a roll equal to the percentage drops the row (boundary is exclusive)", () => {
|
|
335
|
+
const result: ApplyResult = applyRule(
|
|
336
|
+
MetricPipelineRuleType.Sample,
|
|
337
|
+
makeRow(),
|
|
338
|
+
{ matched: true, samplePercentage: 50, sampleRoll: 50 },
|
|
339
|
+
);
|
|
340
|
+
expect(result.row).toBeNull();
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
test("0% drops every matching row", () => {
|
|
344
|
+
const result: ApplyResult = applyRule(
|
|
345
|
+
MetricPipelineRuleType.Sample,
|
|
346
|
+
makeRow(),
|
|
347
|
+
{ matched: true, samplePercentage: 0, sampleRoll: 0 },
|
|
348
|
+
);
|
|
349
|
+
expect(result.row).toBeNull();
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
test("an absent percentage defaults to keeping the row (100%)", () => {
|
|
353
|
+
const result: ApplyResult = applyRule(
|
|
354
|
+
MetricPipelineRuleType.Sample,
|
|
355
|
+
makeRow(),
|
|
356
|
+
{ matched: true, sampleRoll: 99.999 },
|
|
357
|
+
);
|
|
358
|
+
expect(result.row).not.toBeNull();
|
|
359
|
+
});
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
describe("RenameMetric", () => {
|
|
363
|
+
test("renames a matching row's metric name", () => {
|
|
364
|
+
const row: FakeRow = makeRow();
|
|
365
|
+
applyRule(MetricPipelineRuleType.RenameMetric, row, {
|
|
366
|
+
matched: true,
|
|
367
|
+
renameMetricTo: "requests_total",
|
|
368
|
+
});
|
|
369
|
+
expect(row.name).toBe("requests_total");
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
test("leaves the name intact when no target is provided", () => {
|
|
373
|
+
const row: FakeRow = makeRow();
|
|
374
|
+
applyRule(MetricPipelineRuleType.RenameMetric, row, { matched: true });
|
|
375
|
+
expect(row.name).toBe("http_requests_total");
|
|
376
|
+
});
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
describe("RenameAttribute", () => {
|
|
380
|
+
test("moves the value from the old key to the new key", () => {
|
|
381
|
+
const row: FakeRow = makeRow();
|
|
382
|
+
applyRule(MetricPipelineRuleType.RenameAttribute, row, {
|
|
383
|
+
matched: true,
|
|
384
|
+
renameFromKey: "host",
|
|
385
|
+
renameToKey: "hostname",
|
|
386
|
+
});
|
|
387
|
+
expect(row.attributes).toEqual({ hostname: "a", env: "prod" });
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
test("is a no-op when the source key is absent", () => {
|
|
391
|
+
const row: FakeRow = makeRow();
|
|
392
|
+
applyRule(MetricPipelineRuleType.RenameAttribute, row, {
|
|
393
|
+
matched: true,
|
|
394
|
+
renameFromKey: "missing",
|
|
395
|
+
renameToKey: "hostname",
|
|
396
|
+
});
|
|
397
|
+
expect(row.attributes).toEqual({ host: "a", env: "prod" });
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
test("is a no-op when either key is empty", () => {
|
|
401
|
+
const row: FakeRow = makeRow();
|
|
402
|
+
applyRule(MetricPipelineRuleType.RenameAttribute, row, {
|
|
403
|
+
matched: true,
|
|
404
|
+
renameFromKey: "host",
|
|
405
|
+
renameToKey: "",
|
|
406
|
+
});
|
|
407
|
+
expect(row.attributes).toEqual({ host: "a", env: "prod" });
|
|
408
|
+
});
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
describe("AddAttribute", () => {
|
|
412
|
+
test("adds a new attribute with its value", () => {
|
|
413
|
+
const row: FakeRow = makeRow();
|
|
414
|
+
applyRule(MetricPipelineRuleType.AddAttribute, row, {
|
|
415
|
+
matched: true,
|
|
416
|
+
attributeKey: "region",
|
|
417
|
+
attributeValue: "us-east-1",
|
|
418
|
+
});
|
|
419
|
+
expect(row.attributes["region"]).toBe("us-east-1");
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
test("adds an empty-string value when none is supplied", () => {
|
|
423
|
+
const row: FakeRow = makeRow();
|
|
424
|
+
applyRule(MetricPipelineRuleType.AddAttribute, row, {
|
|
425
|
+
matched: true,
|
|
426
|
+
attributeKey: "region",
|
|
427
|
+
});
|
|
428
|
+
expect(row.attributes["region"]).toBe("");
|
|
429
|
+
});
|
|
430
|
+
|
|
431
|
+
test("is a no-op when the key is empty", () => {
|
|
432
|
+
const row: FakeRow = makeRow();
|
|
433
|
+
applyRule(MetricPipelineRuleType.AddAttribute, row, {
|
|
434
|
+
matched: true,
|
|
435
|
+
attributeKey: "",
|
|
436
|
+
attributeValue: "x",
|
|
437
|
+
});
|
|
438
|
+
expect(row.attributes).toEqual({ host: "a", env: "prod" });
|
|
439
|
+
});
|
|
440
|
+
});
|
|
441
|
+
|
|
442
|
+
describe("RemoveAttribute", () => {
|
|
443
|
+
test("removes an existing attribute", () => {
|
|
444
|
+
const row: FakeRow = makeRow();
|
|
445
|
+
applyRule(MetricPipelineRuleType.RemoveAttribute, row, {
|
|
446
|
+
matched: true,
|
|
447
|
+
attributeKey: "env",
|
|
448
|
+
});
|
|
449
|
+
expect(row.attributes).toEqual({ host: "a" });
|
|
450
|
+
});
|
|
451
|
+
|
|
452
|
+
test("is a no-op when the attribute does not exist", () => {
|
|
453
|
+
const row: FakeRow = makeRow();
|
|
454
|
+
applyRule(MetricPipelineRuleType.RemoveAttribute, row, {
|
|
455
|
+
matched: true,
|
|
456
|
+
attributeKey: "missing",
|
|
457
|
+
});
|
|
458
|
+
expect(row.attributes).toEqual({ host: "a", env: "prod" });
|
|
459
|
+
});
|
|
460
|
+
});
|
|
461
|
+
|
|
462
|
+
describe("RedactAttribute", () => {
|
|
463
|
+
test("replaces an existing attribute value with the replacement", () => {
|
|
464
|
+
const row: FakeRow = makeRow();
|
|
465
|
+
applyRule(MetricPipelineRuleType.RedactAttribute, row, {
|
|
466
|
+
matched: true,
|
|
467
|
+
attributeKey: "host",
|
|
468
|
+
redactReplacement: "***",
|
|
469
|
+
});
|
|
470
|
+
expect(row.attributes["host"]).toBe("***");
|
|
471
|
+
});
|
|
472
|
+
|
|
473
|
+
test("uses the [REDACTED] default when no replacement is provided", () => {
|
|
474
|
+
const row: FakeRow = makeRow();
|
|
475
|
+
applyRule(MetricPipelineRuleType.RedactAttribute, row, {
|
|
476
|
+
matched: true,
|
|
477
|
+
attributeKey: "host",
|
|
478
|
+
});
|
|
479
|
+
expect(row.attributes["host"]).toBe("[REDACTED]");
|
|
480
|
+
});
|
|
481
|
+
|
|
482
|
+
test("is a no-op when the attribute does not exist", () => {
|
|
483
|
+
const row: FakeRow = makeRow();
|
|
484
|
+
applyRule(MetricPipelineRuleType.RedactAttribute, row, {
|
|
485
|
+
matched: true,
|
|
486
|
+
attributeKey: "missing",
|
|
487
|
+
});
|
|
488
|
+
expect(row.attributes).toEqual({ host: "a", env: "prod" });
|
|
489
|
+
});
|
|
490
|
+
});
|
|
491
|
+
|
|
492
|
+
describe("unknown / future rule value (default branch)", () => {
|
|
493
|
+
test("keeps the row and flags the default path for an unrecognised value", () => {
|
|
494
|
+
const row: FakeRow = makeRow();
|
|
495
|
+
const result: ApplyResult = applyRule(
|
|
496
|
+
"SomeFutureType" as MetricPipelineRuleType,
|
|
497
|
+
row,
|
|
498
|
+
{ matched: true },
|
|
499
|
+
);
|
|
500
|
+
|
|
501
|
+
expect(result.hitDefault).toBe(true);
|
|
502
|
+
expect(result.row).toBe(row);
|
|
503
|
+
expect(row.attributes).toEqual({ host: "a", env: "prod" });
|
|
504
|
+
});
|
|
505
|
+
|
|
506
|
+
test("every real enum value avoids the default branch", () => {
|
|
507
|
+
for (const ruleType of Object.values(MetricPipelineRuleType)) {
|
|
508
|
+
const result: ApplyResult = applyRule(ruleType, makeRow(), {
|
|
509
|
+
matched: true,
|
|
510
|
+
samplePercentage: 100,
|
|
511
|
+
sampleRoll: 0,
|
|
512
|
+
});
|
|
513
|
+
expect(result.hitDefault).toBe(false);
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
});
|
|
517
|
+
});
|