@oneuptime/common 13.0.5 → 13.0.6
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/AnalyticsModels/AuditLog.ts +81 -1
- package/Models/AnalyticsModels/SecurityEvent.ts +4 -4
- package/Models/DatabaseModels/Alert.ts +62 -0
- package/Models/DatabaseModels/GlobalConfig.ts +1 -1
- package/Models/DatabaseModels/Incident.ts +66 -0
- package/Models/DatabaseModels/IncidentEpisodePublicNote.ts +74 -0
- package/Models/DatabaseModels/IncidentPublicNote.ts +74 -0
- package/Models/DatabaseModels/Index.ts +6 -4
- package/Models/DatabaseModels/NetworkDevice.ts +67 -0
- package/Models/DatabaseModels/NetworkDeviceDiagnostic.ts +746 -0
- package/Models/DatabaseModels/NetworkDeviceDiscoveryScan.ts +151 -0
- package/Models/DatabaseModels/NetworkSiteAssignmentRule.ts +1 -1
- package/Models/DatabaseModels/Project.ts +41 -0
- package/Models/DatabaseModels/ScheduledMaintenancePublicNote.ts +74 -0
- package/Models/DatabaseModels/SecurityEventConnection.ts +11 -11
- package/Models/DatabaseModels/ServiceLevelObjective.ts +185 -8
- package/Models/DatabaseModels/ServiceLevelObjectiveBurnRateRule.ts +746 -43
- package/Models/DatabaseModels/ServiceLevelObjectiveFeed.ts +575 -0
- package/Models/DatabaseModels/ServiceLevelObjectiveMonitorRule.ts +582 -0
- package/Models/DatabaseModels/ServiceLevelObjectiveOwnerTeam.ts +16 -0
- package/Models/DatabaseModels/ServiceLevelObjectiveOwnerUser.ts +16 -0
- package/Models/DatabaseModels/StatusPageAnnouncement.ts +75 -0
- package/Models/DatabaseModels/ThreatIntelFeed.ts +1 -1
- package/Server/API/BaseAPI.ts +17 -0
- package/Server/API/BillingInvoiceAPI.ts +343 -30
- package/Server/API/BillingPaymentMethodAPI.ts +126 -5
- package/Server/API/DashboardAPI.ts +96 -2
- package/Server/API/SecurityEventConnectionAPI.ts +141 -11
- package/Server/API/StatusPageAPI.ts +308 -199
- package/Server/Infrastructure/Postgres/SchemaMigrations/1792800000000-AddNetworkDeviceDiagnostic.ts +83 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1792900000000-AddNetworkDeviceDnsNameAndShortDeviceNames.ts +36 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1793000000000-AddNetbiosLookupToNetworkDeviceDiscoveryScan.ts +29 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1793100000000-SloProductOverhaul.ts +516 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1793200000000-BackfillSloMonitorRulesAndAffectedResources.ts +98 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1793300000000-AddDataResidencyToProject.ts +27 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1793400000000-AddSubscriberUpdateNotificationStatus.ts +97 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +14 -0
- package/Server/Services/AlertEpisodeLabelRuleEngineService.ts +138 -67
- package/Server/Services/AlertEpisodeOwnerRuleEngineService.ts +213 -84
- package/Server/Services/AlertEpisodePrivacyRuleEngineService.ts +112 -35
- package/Server/Services/AlertLabelRuleEngineService.ts +299 -217
- package/Server/Services/AlertOwnerRuleEngineService.ts +572 -396
- package/Server/Services/AlertPrivacyRuleEngineService.ts +116 -40
- package/Server/Services/AlertService.ts +111 -4
- package/Server/Services/AuditLogService.ts +612 -59
- package/Server/Services/BillingInvoiceService.ts +112 -102
- package/Server/Services/BillingService.ts +539 -11
- package/Server/Services/CephClusterLabelRuleEngineService.ts +170 -109
- package/Server/Services/CephClusterOwnerRuleEngineService.ts +233 -115
- package/Server/Services/CloudResourceLabelRuleEngineService.ts +163 -100
- package/Server/Services/CloudResourceOwnerRuleEngineService.ts +236 -115
- package/Server/Services/DashboardLabelRuleEngineService.ts +145 -84
- package/Server/Services/DashboardOwnerRuleEngineService.ts +213 -95
- package/Server/Services/DatabaseService.ts +171 -21
- package/Server/Services/DockerHostLabelRuleEngineService.ts +171 -110
- package/Server/Services/DockerHostOwnerRuleEngineService.ts +233 -115
- package/Server/Services/DockerSwarmClusterLabelRuleEngineService.ts +181 -112
- package/Server/Services/DockerSwarmClusterOwnerRuleEngineService.ts +243 -118
- package/Server/Services/HostLabelRuleEngineService.ts +167 -106
- package/Server/Services/HostOwnerRuleEngineService.ts +229 -111
- package/Server/Services/IncidentEpisodeLabelRuleEngineService.ts +141 -67
- package/Server/Services/IncidentEpisodeOwnerRuleEngineService.ts +272 -72
- package/Server/Services/IncidentEpisodePrivacyRuleEngineService.ts +112 -35
- package/Server/Services/IncidentEpisodePublicNoteService.ts +24 -0
- package/Server/Services/IncidentLabelRuleEngineService.ts +279 -204
- package/Server/Services/IncidentOwnerRuleEngineService.ts +595 -425
- package/Server/Services/IncidentPrivacyRuleEngineService.ts +117 -44
- package/Server/Services/IncidentPublicNoteService.ts +24 -0
- package/Server/Services/IncidentService.ts +114 -3
- package/Server/Services/IncomingCallPolicyLabelRuleEngineService.ts +147 -83
- package/Server/Services/IncomingCallPolicyOwnerRuleEngineService.ts +221 -100
- package/Server/Services/Index.ts +6 -4
- package/Server/Services/IoTFleetLabelRuleEngineService.ts +145 -84
- package/Server/Services/IoTFleetOwnerRuleEngineService.ts +213 -95
- package/Server/Services/KubernetesClusterLabelRuleEngineService.ts +181 -112
- package/Server/Services/KubernetesClusterOwnerRuleEngineService.ts +243 -118
- package/Server/Services/LabelService.ts +23 -28
- package/Server/Services/MonitorLabelRuleEngineService.ts +152 -92
- package/Server/Services/MonitorOwnerRuleEngineService.ts +220 -104
- package/Server/Services/MonitorProbeService.ts +20 -2
- package/Server/Services/MonitorService.ts +11 -9
- package/Server/Services/NetworkDeviceAutoImportRuleEngineService.ts +376 -5
- package/Server/Services/NetworkDeviceDiagnosticService.ts +417 -0
- package/Server/Services/NetworkDeviceLabelRuleEngineService.ts +147 -83
- package/Server/Services/NetworkDeviceOwnerRuleEngineService.ts +218 -97
- package/Server/Services/NetworkDeviceService.ts +39 -2
- package/Server/Services/OnCallDutyPolicyLabelRuleEngineService.ts +151 -80
- package/Server/Services/OnCallDutyPolicyOwnerRuleEngineService.ts +222 -97
- package/Server/Services/OnCallDutyPolicyScheduleLabelRuleEngineService.ts +154 -83
- package/Server/Services/OnCallDutyPolicyScheduleOwnerRuleEngineService.ts +225 -100
- package/Server/Services/PodmanHostLabelRuleEngineService.ts +171 -110
- package/Server/Services/PodmanHostOwnerRuleEngineService.ts +235 -115
- package/Server/Services/ProjectService.ts +111 -10
- package/Server/Services/ProxmoxClusterLabelRuleEngineService.ts +174 -110
- package/Server/Services/ProxmoxClusterOwnerRuleEngineService.ts +239 -116
- package/Server/Services/RumApplicationLabelRuleEngineService.ts +137 -73
- package/Server/Services/RumApplicationOwnerRuleEngineService.ts +200 -83
- package/Server/Services/RunbookLabelRuleEngineService.ts +146 -84
- package/Server/Services/RunbookOwnerRuleEngineService.ts +216 -95
- package/Server/Services/ScheduledMaintenanceLabelRuleEngineService.ts +324 -230
- package/Server/Services/ScheduledMaintenanceOwnerRuleEngineService.ts +613 -428
- package/Server/Services/ScheduledMaintenancePublicNoteService.ts +24 -0
- package/Server/Services/ScheduledMaintenanceService.ts +43 -14
- package/Server/Services/SecurityEventConnectionService.ts +56 -4
- package/Server/Services/ServerlessFunctionLabelRuleEngineService.ts +143 -74
- package/Server/Services/ServerlessFunctionOwnerRuleEngineService.ts +206 -85
- package/Server/Services/ServiceLabelRuleEngineService.ts +172 -110
- package/Server/Services/ServiceLevelObjectiveBurnRateRuleService.ts +1057 -18
- package/Server/Services/ServiceLevelObjectiveFeedService.ts +108 -0
- package/Server/Services/ServiceLevelObjectiveMonitorRuleEngineService.ts +793 -97
- package/Server/Services/ServiceLevelObjectiveMonitorRuleService.ts +1069 -0
- package/Server/Services/ServiceLevelObjectiveOwnerTeamService.ts +240 -1
- package/Server/Services/ServiceLevelObjectiveOwnerUserService.ts +257 -1
- package/Server/Services/ServiceLevelObjectiveService.ts +1356 -56
- package/Server/Services/ServiceOwnerRuleEngineService.ts +238 -116
- package/Server/Services/StatusPageAnnouncementService.ts +13 -0
- package/Server/Services/StatusPageLabelRuleEngineService.ts +146 -85
- package/Server/Services/StatusPageOwnerRuleEngineService.ts +210 -99
- package/Server/Services/StatusPageSubscriberNotificationTemplateService.ts +28 -232
- package/Server/Services/StatusPageSubscriberService.ts +6 -0
- package/Server/Services/TelemetryUsageBillingService.ts +38 -7
- package/Server/Services/ThreatIntelFeedService.ts +1 -1
- package/Server/Services/VMwareVCenterLabelRuleEngineService.ts +173 -110
- package/Server/Services/VMwareVCenterOwnerRuleEngineService.ts +238 -116
- package/Server/Services/WorkflowLabelRuleEngineService.ts +145 -84
- package/Server/Services/WorkflowOwnerRuleEngineService.ts +215 -95
- package/Server/Types/Database/UpdateByID.ts +3 -0
- package/Server/Types/Database/UpdateOneBy.ts +7 -0
- package/Server/Utils/AI/AlertAIContextBuilder.ts +19 -0
- package/Server/Utils/AI/IncidentAIContextBuilder.ts +39 -0
- package/Server/Utils/AI/Toolbox/AlertTools.ts +37 -1
- package/Server/Utils/AI/Toolbox/IncidentTools.ts +22 -1
- package/Server/Utils/AI/Toolbox/SloTools.ts +416 -51
- package/Server/Utils/Dashboard/PublicDashboardResourceListPolicy.ts +151 -13
- package/Server/Utils/Dashboard/PublicDashboardSloHistoryPolicy.ts +17 -4
- package/Server/Utils/Dashboard/PublicDashboardSloWidget.ts +155 -8
- package/Server/Utils/Database/ProjectScopedReferenceValidator.ts +16 -0
- package/Server/Utils/Database/RelationValueUtil.ts +106 -0
- package/Server/Utils/Monitor/Criteria/CompareCriteria.ts +6 -1
- package/Server/Utils/Monitor/Criteria/EvaluateOverTime.ts +22 -27
- package/Server/Utils/Monitor/MonitorCriteriaExpectationBuilder.ts +3 -1
- package/Server/Utils/Monitor/MonitorStepsProjectValidator.ts +50 -20
- package/Server/Utils/Monitor/NetworkDeviceHydrationUtil.ts +13 -1
- package/Server/Utils/Monitor/NetworkDeviceMetricUtil.ts +6 -11
- package/Server/Utils/Rules/MonitorRulePatternValidator.ts +51 -0
- package/Server/Utils/Rules/OwnerRuleAssignment.ts +110 -0
- package/Server/Utils/Rules/RuleRun/RuleApplication.ts +81 -0
- package/Server/Utils/Rules/RuleRun/RuleRunPermission.ts +188 -0
- package/Server/Utils/Rules/RuleRun/RuleRunRegistry.ts +803 -0
- package/Server/Utils/Rules/RuleRun/RuleRunner.ts +341 -0
- package/Server/Utils/SecurityEvent/ConnectorErrorMessage.ts +3 -2
- package/Server/Utils/SecurityEvent/Connectors/ConnectorPlatformHealth.ts +6 -4
- package/Server/Utils/SecurityEvent/{GoogleSecOps → Connectors/GoogleSecOps}/GoogleSecOpsClient.ts +263 -16
- package/Server/Utils/SecurityEvent/Connectors/GoogleSecOps/GoogleSecOpsConnector.ts +2101 -0
- package/Server/Utils/SecurityEvent/Connectors/SecurityEventConnectionPoller.ts +194 -14
- package/Server/Utils/SecurityEvent/Connectors/SecurityEventConnectionRunExecutor.ts +1 -2
- package/Server/Utils/SecurityEvent/Connectors/SecurityEventConnectionTester.ts +38 -7
- package/Server/Utils/SecurityEvent/Connectors/SecurityEventConnectorRegistry.ts +2 -0
- package/Server/Utils/SecurityEvent/Connectors/Types.ts +242 -2
- package/Server/Utils/SecurityEvent/DetectionRuleEvaluator.ts +1 -1
- package/Server/Utils/SecurityEvent/SecurityEventDedupe.ts +3 -3
- package/Server/Utils/SecurityEvent/ThreatIntel/ThreatIntelFeedPoller.ts +2 -2
- package/Server/Utils/SessionReplay/SessionReplayReadService.ts +217 -56
- package/Server/Utils/Slo/SloFeedUtil.ts +200 -0
- package/Server/Utils/Slo/SloLegacyMonitorLabelAdoption.ts +173 -0
- package/Server/Utils/Slo/SloMetricUtil.ts +327 -0
- package/Server/Utils/Slo/SloOwnerReferenceValidator.ts +208 -0
- package/Server/Utils/Slo/SloRecordReferenceValidator.ts +169 -0
- package/Server/Utils/StatusPage/MonitorRulePatternValidator.ts +6 -43
- package/Server/Utils/StatusPageResource.ts +50 -5
- package/Tests/App/Dashboard/AIInvestigationHeaderStatus.test.tsx +664 -15
- package/Tests/App/Dashboard/AddWidgetModal.test.tsx +4 -1
- package/Tests/App/Dashboard/AffectedResourcesSlo.test.tsx +307 -0
- package/Tests/App/Dashboard/ArchiveResourceCard.test.tsx +289 -0
- package/Tests/App/Dashboard/AuditLogsTable.test.tsx +598 -0
- package/Tests/App/Dashboard/BillingDefaultPaymentMethod.test.tsx +1046 -0
- package/Tests/App/Dashboard/BillingPaidUsageFlow.test.tsx +3 -0
- package/Tests/App/Dashboard/BillingPaymentMethodForm.test.tsx +201 -7
- package/Tests/App/Dashboard/BooleanSeriesCriteriaFilterText.test.ts +82 -0
- package/Tests/App/Dashboard/BreadcrumbCoverage.test.tsx +16 -1
- package/Tests/App/Dashboard/ChangeAlertStateAIHeader.test.tsx +116 -8
- package/Tests/App/Dashboard/ChatActivityFeed.test.tsx +168 -1
- package/Tests/App/Dashboard/ConnectionTestModal.test.tsx +1 -1
- package/Tests/App/Dashboard/ConnectorTestReportView.test.tsx +20 -3
- package/Tests/App/Dashboard/CorrelateFilterBuilder.test.tsx +1095 -1
- package/Tests/App/Dashboard/CorrelateFilterChips.test.tsx +910 -0
- package/Tests/App/Dashboard/CorrelateGraph.test.tsx +3747 -25
- package/Tests/App/Dashboard/CorrelateGraphHelpers.test.ts +1085 -0
- package/Tests/App/Dashboard/CorrelateInspector.test.tsx +1534 -0
- package/Tests/App/Dashboard/CorrelateNodeCard.test.tsx +965 -0
- package/Tests/App/Dashboard/CorrelateResultSummary.test.tsx +1525 -0
- package/Tests/App/Dashboard/CorrelationGraph.test.ts +1030 -0
- package/Tests/App/Dashboard/CorrelationGraphLayout.test.ts +526 -0
- package/Tests/App/Dashboard/DeviceDiagnostics.test.tsx +787 -0
- package/Tests/App/Dashboard/DeviceLatencyTrend.test.tsx +278 -0
- package/Tests/App/Dashboard/DiscoveryReviewInventoryRefresh.test.tsx +279 -0
- package/Tests/App/Dashboard/DiscoveryScanEditForm.test.tsx +87 -0
- package/Tests/App/Dashboard/DiscoveryScanWizardValidation.test.tsx +443 -8
- package/Tests/App/Dashboard/EntityFilterDropdownArchivedSlos.test.tsx +340 -0
- package/Tests/App/Dashboard/EventOverviewPages.test.tsx +98 -2
- package/Tests/App/Dashboard/ExceptionSegmentedControl.test.tsx +1020 -0
- package/Tests/App/Dashboard/InvestigationEvidenceList.test.tsx +268 -47
- package/Tests/App/Dashboard/InvestigationPanel.test.tsx +1114 -76
- package/Tests/App/Dashboard/InvestigationPanelStatus.test.tsx +124 -2
- package/Tests/App/Dashboard/InvestigationReportView.test.tsx +279 -176
- package/Tests/App/Dashboard/InvestigationRunDetails.test.tsx +1166 -0
- package/Tests/App/Dashboard/InvoicesPayInvoice.test.tsx +437 -0
- package/Tests/App/Dashboard/NetworkDeviceBulkDelete.test.tsx +65 -0
- package/Tests/App/Dashboard/NetworkTopologyLiveView.test.tsx +5 -0
- package/Tests/App/Dashboard/ResourceAuditLogsSideMenus.test.tsx +74 -0
- package/Tests/App/Dashboard/ResourceFeed.test.tsx +125 -5
- package/Tests/App/Dashboard/ResourceFeedPageWiring.test.ts +8 -1
- package/Tests/App/Dashboard/SecurityEventConnectionDiagnostics.test.tsx +1764 -0
- package/Tests/App/Dashboard/SecurityEventConnectionFormModal.test.tsx +1000 -64
- package/Tests/App/Dashboard/SecurityEventConnectionsEmptyState.test.tsx +448 -0
- package/Tests/App/Dashboard/SecurityEventConnectionsTable.test.tsx +739 -189
- package/Tests/App/Dashboard/SecurityEventSeverityPill.test.tsx +233 -0
- package/Tests/App/Dashboard/SecurityEventsEmptyState.test.tsx +282 -0
- package/Tests/App/Dashboard/SloActiveBurnEventsCard.test.tsx +538 -0
- package/Tests/App/Dashboard/SloBulkActionsArchive.test.tsx +252 -0
- package/Tests/App/Dashboard/SloDashboardTemplateWidgets.test.tsx +322 -518
- package/Tests/App/Dashboard/SloElement.test.tsx +194 -0
- package/Tests/App/Dashboard/SloFeed.test.tsx +289 -0
- package/Tests/App/Dashboard/SloHistoryCharts.test.tsx +471 -0
- package/Tests/App/Dashboard/SloHistorySeries.test.tsx +607 -0
- package/Tests/App/Dashboard/SloListWidget.test.tsx +783 -0
- package/Tests/App/Dashboard/SloMetricsPage.test.tsx +346 -0
- package/Tests/App/Dashboard/SloMonitorsPage.test.tsx +661 -0
- package/Tests/App/Dashboard/SloMonitorsSummaryCard.test.tsx +489 -0
- package/Tests/App/Dashboard/SloNavigationWiring.test.tsx +437 -0
- package/Tests/App/Dashboard/SloNoticeBanner.test.tsx +305 -0
- package/Tests/App/Dashboard/SloOverviewData.test.tsx +563 -0
- package/Tests/App/Dashboard/SloOverviewHero.test.tsx +311 -0
- package/Tests/App/Dashboard/SloOverviewKpiStrip.test.tsx +426 -0
- package/Tests/App/Dashboard/SloOverviewSidebarCards.test.tsx +493 -0
- package/Tests/App/Dashboard/SloSettings.test.tsx +633 -0
- package/Tests/App/Dashboard/SloStatusSummaryCards.test.tsx +403 -0
- package/Tests/App/Dashboard/SloViewSideMenuCounts.test.tsx +373 -0
- package/Tests/App/Dashboard/SloWidgetVariableBinding.test.tsx +689 -0
- package/Tests/App/Dashboard/TopologyConnectivitySection.test.tsx +206 -0
- package/Tests/App/Dashboard/TracesEntityNames.test.tsx +47 -15
- package/Tests/App/Dashboard/UseBulkShortenDeviceNames.test.tsx +1312 -0
- package/Tests/App/Dashboard/WidgetCatalog.test.ts +9 -1
- package/Tests/Models/AnalyticsModels/RumSessionReplayColumns.test.ts +14 -16
- package/Tests/Models/DatabaseModels/AuditLogModelConfiguration.test.ts +442 -0
- package/Tests/Models/DatabaseModels/DomainRoleTierCoverage.test.ts +9 -10
- package/Tests/Models/DatabaseModels/ResourceFeedModels.test.ts +48 -1
- package/Tests/Models/DatabaseModels/SloOverhaulModels.test.ts +835 -0
- package/Tests/Models/DatabaseModels/StaticRuleCriteriaInheritance.test.ts +3 -2
- package/Tests/Models/DiscoveryScanNetbiosLookupColumn.test.ts +328 -0
- package/Tests/Models/DiscoveryScanShortDeviceNamesColumn.test.ts +335 -0
- package/Tests/Models/NetworkDeviceDiagnosticContract.test.ts +194 -0
- package/Tests/Models/NetworkDeviceDnsNameColumn.test.ts +321 -0
- package/Tests/Models/ProjectDataResidencyColumn.test.ts +154 -0
- package/Tests/Models/SecurityDomainAccessControl.test.ts +181 -50
- package/Tests/Server/API/BaseAPI.test.ts +6 -0
- package/Tests/Server/API/BaseAPIUpdateMiscDataProps.test.ts +217 -0
- package/Tests/Server/API/BillingInvoiceAPI.test.ts +7 -0
- package/Tests/Server/API/BillingInvoiceAPIPaymentStates.test.ts +990 -0
- package/Tests/Server/API/BillingPaymentMethodAPI.test.ts +498 -0
- package/Tests/Server/API/DashboardPublicSloAPI.test.ts +405 -0
- package/Tests/Server/API/SecurityEventConnectionAPI.test.ts +901 -7
- package/Tests/Server/API/SessionReplayAPI.test.ts +116 -0
- package/Tests/Server/API/StatusPageManageSubscriptionRecipient.test.ts +857 -0
- package/Tests/Server/API/StatusPageManageSubscriptionTemplateVariables.test.ts +1084 -0
- package/Tests/Server/Infrastructure/Postgres/AddConfigurableRuleCriteriaMigration.test.ts +33 -3
- package/Tests/Server/Infrastructure/Postgres/AddDataResidencyToProjectMigration.test.ts +202 -0
- package/Tests/Server/Infrastructure/Postgres/AddNetbiosLookupToNetworkDeviceDiscoveryScanMigration.test.ts +330 -0
- package/Tests/Server/Infrastructure/Postgres/AddNetworkDeviceDnsNameAndShortDeviceNamesMigration.test.ts +340 -0
- package/Tests/Server/Infrastructure/Postgres/BackfillSloMonitorRulesAndAffectedResourcesMigration.test.ts +343 -0
- package/Tests/Server/Infrastructure/Postgres/SloProductOverhaulMigration.test.ts +801 -0
- package/Tests/Server/Services/AddSubscriberUpdateNotificationStatusMigration.test.ts +307 -0
- package/Tests/Server/Services/AuditLogService.test.ts +1124 -0
- package/Tests/Server/Services/AutoImportScanCredentialSelect.test.ts +200 -1
- package/Tests/Server/Services/BillingInvoiceServiceMutexRelease.test.ts +254 -0
- package/Tests/Server/Services/BillingService.test.ts +70 -0
- package/Tests/Server/Services/BillingServicePayInvoiceStates.test.ts +723 -0
- package/Tests/Server/Services/BillingServicePaymentMethodReads.test.ts +14 -2
- package/Tests/Server/Services/BillingServiceSubscriptionPaymentMethodSync.test.ts +1634 -0
- package/Tests/Server/Services/DatabaseServiceAuditRelationDiff.test.ts +492 -0
- package/Tests/Server/Services/DatabaseServicePasswordFieldSecrets.test.ts +629 -0
- package/Tests/Server/Services/IncidentAlertSloLinkSurvivesEdit.test.ts +431 -0
- package/Tests/Server/Services/IncidentAlertSloReferenceGuard.test.ts +358 -0
- package/Tests/Server/Services/MonitorProbeServicePastDueMonitoring.test.ts +362 -0
- package/Tests/Server/Services/NetworkDeviceAutoImportRuleEngineService.test.ts +1460 -1
- package/Tests/Server/Services/NetworkDeviceDiagnosticService.test.ts +962 -0
- package/Tests/Server/Services/NetworkDeviceDiscoveryScanService.test.ts +106 -0
- package/Tests/Server/Services/NetworkDeviceRuleEngines.test.ts +10 -1
- package/Tests/Server/Services/NetworkDeviceServicePastDueMonitoring.test.ts +335 -0
- package/Tests/Server/Services/NetworkDeviceSiteRuleDnsName.test.ts +568 -0
- package/Tests/Server/Services/ProjectDataResidencyPostgres.test.ts +344 -0
- package/Tests/Server/Services/ProjectServiceAuditLogSettingsCache.test.ts +187 -0
- package/Tests/Server/Services/ProjectServiceDataResidency.test.ts +369 -0
- package/Tests/Server/Services/ProjectServiceDataResidencySelfHosted.test.ts +176 -0
- package/Tests/Server/Services/ProjectServicePastDueMonitoring.test.ts +289 -0
- package/Tests/Server/Services/ResourceFeedServices.test.ts +24 -8
- package/Tests/Server/Services/RuleRun/IncidentAlertMaintenanceRuleEnginesRun.test.ts +1396 -0
- package/Tests/Server/Services/RuleRun/LabelRuleEnginesGroupARun.test.ts +917 -0
- package/Tests/Server/Services/RuleRun/LabelRuleEnginesGroupBRun.test.ts +1262 -0
- package/Tests/Server/Services/RuleRun/OwnerRuleEnginesGroupARun.test.ts +902 -0
- package/Tests/Server/Services/RuleRun/OwnerRuleEnginesGroupBRun.test.ts +1163 -0
- package/Tests/Server/Services/RuleRun/PrivacyRuleEnginesRun.test.ts +843 -0
- package/Tests/Server/Services/ScheduledMaintenanceSubscriberTemplateFormats.test.ts +465 -0
- package/Tests/Server/Services/SecurityEventConnectionService.test.ts +525 -4
- package/Tests/Server/Services/SecurityEventLastErrorColumnWidth.test.ts +77 -23
- package/Tests/Server/Services/ServiceLevelObjectiveBurnRateRuleFeedWrites.test.ts +777 -0
- package/Tests/Server/Services/ServiceLevelObjectiveBurnRateRuleOptions.test.ts +1399 -0
- package/Tests/Server/Services/ServiceLevelObjectiveBurnRateRuleService.test.ts +67 -74
- package/Tests/Server/Services/ServiceLevelObjectiveChildRowTenancy.test.ts +906 -0
- package/Tests/Server/Services/ServiceLevelObjectiveDeleteTenancy.test.ts +1029 -0
- package/Tests/Server/Services/ServiceLevelObjectiveFeedService.test.ts +313 -0
- package/Tests/Server/Services/ServiceLevelObjectiveFeedWrites.test.ts +1214 -0
- package/Tests/Server/Services/ServiceLevelObjectiveMarkdownLink.test.ts +289 -0
- package/Tests/Server/Services/ServiceLevelObjectiveMonitorRuleEngineService.test.ts +1455 -430
- package/Tests/Server/Services/ServiceLevelObjectiveMonitorRuleLegacyLabelAdoption.test.ts +634 -0
- package/Tests/Server/Services/ServiceLevelObjectiveMonitorRuleService.test.ts +1193 -0
- package/Tests/Server/Services/{SloMonitorLabelRuleHooks.test.ts → ServiceLevelObjectiveMonitorRuleTriggers.test.ts} +135 -41
- package/Tests/Server/Services/ServiceLevelObjectiveOwnerFeedWrites.test.ts +671 -0
- package/Tests/Server/Services/ServiceLevelObjectiveService.test.ts +180 -85
- package/Tests/Server/Services/ServiceLevelObjectiveServiceArchive.test.ts +537 -0
- package/Tests/Server/Services/ServiceLevelObjectiveServiceLegacyMonitorLabelWrite.test.ts +870 -0
- package/Tests/Server/Services/ServiceLevelObjectiveServiceMonitorRuleGuard.test.ts +343 -0
- package/Tests/Server/Services/ServiceLevelObjectiveServiceReEvaluation.test.ts +246 -0
- package/Tests/Server/Services/SloAffectedResourceCreatedFeed.test.ts +501 -0
- package/Tests/Server/Services/SloAffectedResourceLinkContract.test.ts +86 -0
- package/Tests/Server/Services/SloAffectedResourceMetricAttributes.test.ts +547 -0
- package/Tests/Server/Services/StaticRuleCriteriaRuntimeCoverage.test.ts +10 -4
- package/Tests/Server/Services/StatusPageMonitorRuleHooks.test.ts +7 -2
- package/Tests/Server/Services/StatusPageSubscriberNotificationTemplateCompile.test.ts +174 -0
- package/Tests/Server/Services/StatusPageSubscriberNotificationTemplateServiceVariables.test.ts +40 -0
- package/Tests/Server/Services/SubscriberUpdateNotificationHooks.test.ts +541 -0
- package/Tests/Server/Services/TelemetryUsageBillingSloExclusion.test.ts +288 -0
- package/Tests/Server/TestingUtils/PastDueMonitoringClaimSql.ts +177 -0
- package/Tests/Server/TestingUtils/Services/BillingServiceHelper.ts +51 -10
- package/Tests/Server/TestingUtils/__mocks__/Stripe.mock.ts +16 -1
- package/Tests/Server/Types/Database/Permissions/ProjectDataResidencyColumn.test.ts +386 -0
- package/Tests/Server/Types/Database/Permissions/SecurityRoleAccess.test.ts +26 -36
- package/Tests/Server/Utils/AI/SloAffectedResourceAIContext.test.ts +445 -0
- package/Tests/Server/Utils/AI/SloTools.test.ts +423 -1
- package/Tests/Server/Utils/AI/SloToolsArchive.test.ts +294 -0
- package/Tests/Server/Utils/AI/SloToolsRuleReadPermissions.test.ts +297 -0
- package/Tests/Server/Utils/Dashboard/PublicDashboardSloHistoryPolicy.test.ts +255 -10
- package/Tests/Server/Utils/Dashboard/SloTemplatePublicDashboard.test.ts +404 -750
- package/Tests/Server/Utils/Database/ProjectScopedReferenceValidator.test.ts +45 -0
- package/Tests/Server/Utils/Database/RelationValueUtil.test.ts +157 -0
- package/Tests/Server/Utils/Monitor/Criteria/BooleanSeriesEvaluateOverTime.test.ts +260 -0
- package/Tests/Server/Utils/Monitor/Criteria/DatabaseMonitorCriteria.test.ts +181 -0
- package/Tests/Server/Utils/Monitor/Criteria/EvaluateOverTime.test.ts +147 -30
- package/Tests/Server/Utils/Monitor/MonitorCriteriaExpectationBuilder.test.ts +17 -0
- package/Tests/Server/Utils/Monitor/MonitorStepsProjectValidator.test.ts +136 -0
- package/Tests/Server/Utils/Monitor/MonitorStepsProjectValidatorLoadOrder.test.ts +472 -0
- package/Tests/Server/Utils/Monitor/NetworkDeviceHydrationUtil.test.ts +48 -2
- package/Tests/Server/Utils/Monitor/SloTemplateMetricEmitterContract.test.ts +435 -475
- package/Tests/Server/Utils/Rules/MonitorRulePatternValidator.test.ts +77 -0
- package/Tests/Server/Utils/Rules/OwnerRuleAssignment.test.ts +177 -0
- package/Tests/Server/Utils/Rules/RuleRun/RuleRunPermission.test.ts +365 -0
- package/Tests/Server/Utils/Rules/RuleRun/RuleRunRegistry.test.ts +173 -0
- package/Tests/Server/Utils/Rules/RuleRun/RuleRunner.test.ts +675 -0
- package/Tests/Server/Utils/SecurityEvent/ConnectorErrorMessage.test.ts +8 -8
- package/Tests/Server/Utils/SecurityEvent/Connectors/ConnectorFetchSummary.test.ts +261 -0
- package/Tests/Server/Utils/SecurityEvent/Connectors/ConnectorPlatformHealth.test.ts +68 -13
- package/Tests/Server/Utils/SecurityEvent/{GoogleSecOpsAuth.test.ts → Connectors/GoogleSecOps/GoogleSecOpsAuth.test.ts} +5 -5
- package/Tests/Server/Utils/SecurityEvent/{GoogleSecOpsClient.test.ts → Connectors/GoogleSecOps/GoogleSecOpsClient.test.ts} +4 -4
- package/Tests/Server/Utils/SecurityEvent/Connectors/GoogleSecOps/GoogleSecOpsConnector.test.ts +483 -0
- package/Tests/Server/Utils/SecurityEvent/Connectors/GoogleSecOps/GoogleSecOpsConnectorCuratedAndLateAlerts.test.ts +676 -0
- package/Tests/Server/Utils/SecurityEvent/Connectors/GoogleSecOps/GoogleSecOpsConnectorFetchEvents.test.ts +1994 -0
- package/Tests/Server/Utils/SecurityEvent/Connectors/GoogleSecOps/GoogleSecOpsConnectorFixtures.ts +332 -0
- package/Tests/Server/Utils/SecurityEvent/Connectors/GoogleSecOps/GoogleSecOpsConnectorHttpIntegration.test.ts +680 -0
- package/Tests/Server/Utils/SecurityEvent/Connectors/GoogleSecOps/GoogleSecOpsConnectorRequestContract.test.ts +1206 -0
- package/Tests/Server/Utils/SecurityEvent/Connectors/GoogleSecOps/GoogleSecOpsConnectorTestConnection.test.ts +1136 -0
- package/Tests/Server/Utils/SecurityEvent/Connectors/GoogleSecOps/GoogleSecOpsCuratedRuleCounts.test.ts +407 -0
- package/Tests/Server/Utils/SecurityEvent/{GoogleSecOpsErrorHandling.test.ts → Connectors/GoogleSecOps/GoogleSecOpsErrorHandling.test.ts} +5 -5
- package/Tests/Server/Utils/SecurityEvent/Connectors/GoogleSecOps/GoogleSecOpsPollingAdaptiveCatchUp.test.ts +730 -0
- package/Tests/Server/Utils/SecurityEvent/{GoogleSecOpsClickhouseIntegration.test.ts → Connectors/GoogleSecOps/GoogleSecOpsPollingClickhouseIntegration.test.ts} +130 -35
- package/Tests/Server/Utils/SecurityEvent/Connectors/GoogleSecOps/GoogleSecOpsPollingFailureTaxonomy.test.ts +772 -0
- package/Tests/Server/Utils/SecurityEvent/Connectors/GoogleSecOps/GoogleSecOpsPollingFixtures.ts +648 -0
- package/Tests/Server/Utils/SecurityEvent/{GoogleSecOpsHttpIntegration.test.ts → Connectors/GoogleSecOps/GoogleSecOpsPollingHttpIntegration.test.ts} +230 -225
- package/Tests/Server/Utils/SecurityEvent/Connectors/GoogleSecOps/GoogleSecOpsPollingIntegration.test.ts +1390 -0
- package/Tests/Server/Utils/SecurityEvent/Connectors/GoogleSecOps/GoogleSecOpsPollingLoop.test.ts +981 -0
- package/Tests/Server/Utils/SecurityEvent/Connectors/GoogleSecOps/GoogleSecOpsPollingNothingImportedRegression.test.ts +290 -0
- package/Tests/Server/Utils/SecurityEvent/{GoogleSecOpsRequestContract.test.ts → Connectors/GoogleSecOps/GoogleSecOpsRequestContract.test.ts} +2 -2
- package/Tests/Server/Utils/SecurityEvent/{GoogleSecOpsResponseParsing.test.ts → Connectors/GoogleSecOps/GoogleSecOpsResponseParsing.test.ts} +5 -5
- package/Tests/Server/Utils/SecurityEvent/{GoogleSecOpsSearchDetections.test.ts → Connectors/GoogleSecOps/GoogleSecOpsSearchDetections.test.ts} +38 -5
- package/Tests/Server/Utils/SecurityEvent/Connectors/GoogleSecOps/GoogleSecOpsTesterIntegration.test.ts +421 -0
- package/Tests/Server/Utils/SecurityEvent/Connectors/SecurityEventConnectionPoller.test.ts +1445 -3
- package/Tests/Server/Utils/SecurityEvent/Connectors/SecurityEventConnectionRunExecutor.test.ts +14 -4
- package/Tests/Server/Utils/SecurityEvent/Connectors/SecurityEventConnectionTester.test.ts +313 -4
- package/Tests/Server/Utils/SessionReplay/SessionReplayReadServiceQueries.test.ts +352 -0
- package/Tests/Server/Utils/Slo/SloFeedUtil.test.ts +326 -0
- package/Tests/Server/Utils/Slo/SloLegacyMonitorLabelAdoption.test.ts +260 -0
- package/Tests/Server/Utils/Slo/SloMetricUtil.test.ts +592 -0
- package/Tests/Server/Utils/Slo/SloRecordReferenceValidator.test.ts +311 -0
- package/Tests/Server/Utils/StatusPageResource.test.ts +91 -3
- package/Tests/Types/Billing/SubscriptionStatus.test.ts +176 -0
- package/Tests/Types/Billing/SubscriptionStatusPastDueMonitoring.test.ts +187 -0
- package/Tests/Types/Dashboard/DashboardTemplateInvariants.test.ts +53 -7
- package/Tests/Types/Dashboard/SloDashboardTemplate.test.ts +816 -792
- package/Tests/Types/Monitor/CriteriaFilter.test.ts +216 -24
- package/Tests/Types/Monitor/MonitorStepDnssecMonitor.test.ts +14 -1
- package/Tests/Types/Monitor/MonitorStepDomainMonitor.test.ts +14 -1
- package/Tests/Types/Monitor/MonitorStepExternalStatusPageMonitor.test.ts +14 -1
- package/Tests/Types/Monitor/MonitorStepRetriesParsing.test.ts +201 -0
- package/Tests/Types/Rules/RuleRun.test.ts +315 -0
- package/Tests/Types/Rum/SessionReplayApiContracts.test.ts +60 -0
- package/Tests/Types/SecurityEvent/Connectors/SecurityEventConnectorCatalog.test.ts +29 -4
- package/Tests/Types/StatusPage/SubscriberNotificationTemplateVariables.test.ts +217 -0
- package/Tests/Types/StatusPage/SubscriberUpdateNotification.test.ts +200 -0
- package/Tests/UI/Components/ActiveFilterChipsLockedFilters.test.tsx +141 -87
- package/Tests/UI/Components/AlertBanner.test.tsx +319 -0
- package/Tests/UI/Components/BulkArchiveActionsCopy.test.tsx +310 -0
- package/Tests/UI/Components/Detail/DetailIdIsUnique.test.tsx +87 -0
- package/Tests/UI/Components/Dropdown/DropdownClearable.test.tsx +393 -0
- package/Tests/UI/Components/Dropdown/DropdownMultiSelectChipAccessibleName.test.tsx +64 -0
- package/Tests/UI/Components/EmptyState/EmptyState.test.tsx +335 -4
- package/Tests/UI/Components/EmptyState/EmptyStateGuideLinks.test.tsx +337 -0
- package/Tests/UI/Components/Forms/ModelFormJsonColumns.test.tsx +21 -20
- package/Tests/UI/Components/LabelRuleImportExport.test.tsx +15 -2
- package/Tests/UI/Components/LockedFilterChip.test.tsx +281 -144
- package/Tests/UI/Components/MoreMenu.test.tsx +133 -0
- package/Tests/UI/Components/MoreMenuMotion.test.tsx +84 -3
- package/Tests/UI/Components/RuleCriteria/RuleCriteriaModelTable.test.tsx +3 -3
- package/Tests/UI/Components/RuleRun/RuleDetailFields.test.tsx +336 -0
- package/Tests/UI/Components/RuleRun/RuleTable.test.tsx +304 -0
- package/Tests/UI/Components/RuleRun/RunRuleNowModal.test.tsx +231 -0
- package/Tests/UI/Components/RuleRun/RunRulesBulkAction.test.ts +213 -0
- package/Tests/UI/Components/TelemetryActiveFilterChipsLockedFilters.test.tsx +124 -61
- package/Tests/UI/Rum/ReplayEngine.test.ts +154 -0
- package/Tests/UI/Rum/ReplayHeader.test.tsx +234 -123
- package/Tests/UI/Rum/ReplayPinControl.test.tsx +122 -0
- package/Tests/UI/Rum/ReplayPlayerChrome.test.tsx +245 -0
- package/Tests/UI/Rum/ReplayRail.test.tsx +294 -0
- package/Tests/UI/Rum/ReplayScrubber.test.tsx +213 -1
- package/Tests/UI/Rum/ReplayStage.test.tsx +565 -172
- package/Tests/UI/Rum/ReplayStageOverlays.test.tsx +260 -3
- package/Tests/UI/Rum/ReplayTabSwitcher.test.tsx +1391 -0
- package/Tests/UI/Rum/ReplayTimeline.test.tsx +222 -0
- package/Tests/UI/Utils/DashboardStackingLayers.test.ts +8 -1
- package/Tests/UI/Utils/RuleRunClient.test.ts +303 -0
- package/Tests/UI/Utils/Telemetry/TelemetryEntityNames.test.ts +1 -0
- package/Tests/Utils/Dashboard/Components/DashboardComponentDefaults.test.ts +2 -0
- package/Tests/Utils/Dashboard/Components/DashboardSloListComponent.test.ts +206 -0
- package/Tests/Utils/Dashboard/DashboardSloComponent.test.ts +36 -2
- package/Tests/Utils/Dashboard/SloTemplateVariableScoping.test.ts +409 -588
- package/Tests/Utils/Dashboard/SloWidgetSource.test.ts +351 -0
- package/Tests/Utils/Markdown/MarkdownEscape.test.ts +361 -0
- package/Tests/Utils/NetworkDiscovery/DiscoveredDeviceBuilder.test.ts +1425 -118
- package/Tests/Utils/NetworkDiscovery/DiscoveredHostUtil.test.ts +188 -3
- package/Tests/Utils/NetworkDiscovery/DiscoveryReverseDnsChain.test.ts +661 -13
- package/Tests/Utils/NetworkDiscovery/NetbiosNameUtil.test.ts +349 -0
- package/Tests/Utils/NetworkDiscovery/RunImportedDeviceNaming.test.ts +656 -0
- package/Tests/Utils/NetworkDiscovery/ShortDeviceNamePlanner.test.ts +1020 -0
- package/Tests/Utils/NetworkDiscovery/ShortHostnameUtil.test.ts +619 -0
- package/Tests/Utils/NetworkSite/CidrMatchUtil.test.ts +317 -0
- package/Tests/Utils/Project/DataResidency.test.ts +198 -0
- package/Tests/Utils/Rules/RuleRunSummary.test.ts +394 -0
- package/Tests/Utils/Slo/SloAffectedResourceMarkdown.test.ts +302 -0
- package/Tests/Utils/Slo/SloBurnRateTemplate.test.ts +468 -0
- package/Tests/Utils/Slo/SloEvaluation.test.ts +20 -4
- package/Tests/Utils/Slo/SloFeedMarkdown.test.ts +1185 -0
- package/Tests/Utils/Slo/SloHealth.test.ts +262 -0
- package/Tests/Utils/Slo/SloHistoryMetricName.test.ts +102 -0
- package/Tests/Utils/Slo/SloListWidgetFormat.test.ts +522 -0
- package/Tests/Utils/Slo/SloMetricType.test.ts +355 -0
- package/Tests/Utils/Slo/SloMonitorRuleCriteria.test.ts +387 -0
- package/Tests/Utils/Slo/SloMonitorStatusSummary.test.ts +210 -0
- package/Tests/Utils/Slo/SloOverviewText.test.ts +226 -0
- package/Tests/Utils/Slo/SloProjection.test.ts +1039 -0
- package/Tests/Utils/Slo/SloWidgetFormat.test.ts +47 -0
- package/Tests/Utils/Telemetry/LockedFilterSearch.test.ts +1 -80
- package/Types/BaseDatabase/EnableAuditLogOn.ts +41 -0
- package/Types/Billing/SubscriptionStatus.ts +39 -4
- package/Types/Dashboard/DashboardComponentType.ts +1 -0
- package/Types/Dashboard/DashboardComponents/ComponentArgument.ts +5 -0
- package/Types/Dashboard/DashboardComponents/DashboardSloComponent.ts +10 -0
- package/Types/Dashboard/DashboardComponents/DashboardSloListComponent.ts +29 -0
- package/Types/Dashboard/DashboardTemplates.ts +290 -297
- package/Types/Database/EnableAuditLog.ts +23 -1
- package/Types/Email/EmailTemplateType.ts +4 -0
- package/Types/Monitor/CriteriaFilter.ts +55 -8
- package/Types/Monitor/MonitorStep.ts +5 -2
- package/Types/Monitor/MonitorStepDnsMonitor.ts +3 -1
- package/Types/Monitor/MonitorStepDnssecMonitor.ts +3 -1
- package/Types/Monitor/MonitorStepDomainMonitor.ts +3 -1
- package/Types/Monitor/MonitorStepExternalStatusPageMonitor.ts +3 -1
- package/Types/Monitor/MonitorStepRetries.ts +59 -0
- package/Types/Monitor/MonitorStepSnmpMonitor.ts +9 -2
- package/Types/NetworkDevice/NetworkDeviceDiagnosticResult.ts +104 -0
- package/Types/NetworkDevice/NetworkDeviceDiagnosticStatus.ts +47 -0
- package/Types/NetworkDevice/NetworkDeviceDiagnosticType.ts +47 -0
- package/Types/NetworkDevice/NetworkDevicePingMetricNames.ts +20 -0
- package/Types/Permission.ts +127 -0
- package/Types/Rules/RuleCriteriaFieldRegistry.ts +5 -0
- package/Types/Rules/RuleRun.ts +518 -0
- package/Types/Rum/SessionReplayApi.ts +18 -0
- package/Types/SecurityEvent/Connectors/ConnectorDiagnostics.ts +6 -0
- package/Types/SecurityEvent/Connectors/SecurityEventConnectionDiagnostics.ts +30 -4
- package/Types/SecurityEvent/Connectors/SecurityEventConnectorCatalog.ts +108 -1
- package/Types/SecurityEvent/Connectors/SecurityEventConnectorProvider.ts +6 -2
- package/Types/ServiceLevelObjective/SloHistoryMetricName.ts +25 -0
- package/Types/ServiceLevelObjective/SloMetricType.ts +49 -0
- package/Types/StatusPage/StatusPageSubscriberNotificationEventType.ts +4 -0
- package/Types/StatusPage/SubscriberNotificationTemplateVariables.ts +331 -0
- package/Types/StatusPage/SubscriberNotificationTrigger.ts +12 -0
- package/Types/StatusPage/SubscriberUpdateNotification.ts +89 -0
- package/Types/Telemetry/LockedFilterDetail.ts +7 -28
- package/Types/Telemetry/ServiceType.ts +7 -0
- package/Typings/Index.d.ts +53 -3
- package/UI/Components/AlertBanner/AlertBanner.tsx +85 -27
- package/UI/Components/BulkUpdate/BulkArchiveActions.tsx +21 -2
- package/UI/Components/Detail/Detail.tsx +9 -2
- package/UI/Components/Dropdown/Dropdown.tsx +64 -1
- package/UI/Components/EmptyState/EmptyState.tsx +27 -3
- package/UI/Components/EmptyState/EmptyStateGuideLinks.tsx +124 -0
- package/UI/Components/Forms/ModelForm.tsx +6 -5
- package/UI/Components/LabelRule/LabelRuleTable.tsx +8 -2
- package/UI/Components/LogsViewer/LogsViewer.tsx +2 -6
- package/UI/Components/LogsViewer/components/ActiveFilterChips.tsx +2 -13
- package/UI/Components/LogsViewer/types.ts +2 -2
- package/UI/Components/MoreMenu/MoreMenu.tsx +14 -3
- package/UI/Components/RuleRun/RuleDetailFields.tsx +359 -0
- package/UI/Components/RuleRun/RuleTable.tsx +183 -0
- package/UI/Components/RuleRun/RuleView.tsx +170 -0
- package/UI/Components/RuleRun/RunRuleNowModal.tsx +147 -0
- package/UI/Components/RuleRun/RunRulesBulkAction.ts +103 -0
- package/UI/Components/TelemetryViewer/TelemetryViewer.tsx +2 -6
- package/UI/Components/TelemetryViewer/components/LockedFilterChip.tsx +38 -104
- package/UI/Components/TelemetryViewer/components/TelemetryActiveFilterChips.tsx +2 -18
- package/UI/Components/TelemetryViewer/types.ts +2 -2
- package/UI/Utils/Rules/RuleRunClient.ts +178 -0
- package/UI/Utils/Telemetry/TelemetryEntityNames.ts +8 -0
- package/Utils/Dashboard/Components/DashboardSloComponent.ts +19 -2
- package/Utils/Dashboard/Components/DashboardSloListComponent.ts +126 -0
- package/Utils/Dashboard/Components/Index.ts +7 -0
- package/Utils/Dashboard/SloWidgetSource.ts +188 -0
- package/Utils/Markdown/MarkdownEscape.ts +63 -0
- package/Utils/NetworkDiscovery/DiscoveredDeviceBuilder.ts +161 -36
- package/Utils/NetworkDiscovery/DiscoveredHostUtil.ts +25 -0
- package/Utils/NetworkDiscovery/NetbiosNameUtil.ts +146 -0
- package/Utils/NetworkDiscovery/RunImportedDeviceNaming.ts +390 -0
- package/Utils/NetworkDiscovery/ShortDeviceNamePlanner.ts +291 -0
- package/Utils/NetworkDiscovery/ShortHostnameUtil.ts +91 -0
- package/Utils/NetworkSite/CidrMatchUtil.ts +37 -12
- package/Utils/Project/DataResidency.ts +63 -0
- package/Utils/Rules/RuleRunSummary.ts +323 -0
- package/Utils/Slo/SloAffectedResourceMarkdown.ts +123 -0
- package/Utils/Slo/SloBurnRateTemplate.ts +373 -0
- package/Utils/Slo/SloFeedMarkdown.ts +1507 -0
- package/Utils/Slo/SloHealth.ts +96 -9
- package/Utils/Slo/SloListWidgetFormat.ts +370 -0
- package/Utils/Slo/SloMetricType.ts +237 -0
- package/Utils/Slo/SloMonitorRuleCriteria.ts +364 -0
- package/Utils/Slo/SloMonitorStatusSummary.ts +210 -0
- package/Utils/Slo/SloOverviewText.ts +265 -0
- package/Utils/Slo/SloProjection.ts +967 -0
- package/Utils/Slo/SloWidgetFormat.ts +12 -2
- package/Utils/Telemetry/LockedFilterSearch.ts +3 -49
- package/build/dist/Models/AnalyticsModels/AuditLog.js +70 -1
- package/build/dist/Models/AnalyticsModels/AuditLog.js.map +1 -1
- package/build/dist/Models/AnalyticsModels/SecurityEvent.js +4 -4
- package/build/dist/Models/DatabaseModels/Alert.js +60 -0
- package/build/dist/Models/DatabaseModels/Alert.js.map +1 -1
- package/build/dist/Models/DatabaseModels/GlobalConfig.js +1 -1
- package/build/dist/Models/DatabaseModels/GlobalConfig.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Incident.js +64 -0
- package/build/dist/Models/DatabaseModels/Incident.js.map +1 -1
- package/build/dist/Models/DatabaseModels/IncidentEpisodePublicNote.js +75 -0
- package/build/dist/Models/DatabaseModels/IncidentEpisodePublicNote.js.map +1 -1
- package/build/dist/Models/DatabaseModels/IncidentPublicNote.js +75 -0
- package/build/dist/Models/DatabaseModels/IncidentPublicNote.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Index.js +6 -4
- package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
- package/build/dist/Models/DatabaseModels/NetworkDevice.js +68 -0
- package/build/dist/Models/DatabaseModels/NetworkDevice.js.map +1 -1
- package/build/dist/Models/DatabaseModels/NetworkDeviceDiagnostic.js +772 -0
- package/build/dist/Models/DatabaseModels/NetworkDeviceDiagnostic.js.map +1 -0
- package/build/dist/Models/DatabaseModels/NetworkDeviceDiscoveryScan.js +140 -0
- package/build/dist/Models/DatabaseModels/NetworkDeviceDiscoveryScan.js.map +1 -1
- package/build/dist/Models/DatabaseModels/NetworkSiteAssignmentRule.js +1 -1
- package/build/dist/Models/DatabaseModels/NetworkSiteAssignmentRule.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Project.js +42 -0
- package/build/dist/Models/DatabaseModels/Project.js.map +1 -1
- package/build/dist/Models/DatabaseModels/ScheduledMaintenancePublicNote.js +75 -0
- package/build/dist/Models/DatabaseModels/ScheduledMaintenancePublicNote.js.map +1 -1
- package/build/dist/Models/DatabaseModels/SecurityEventConnection.js +11 -11
- package/build/dist/Models/DatabaseModels/ServiceLevelObjective.js +192 -10
- package/build/dist/Models/DatabaseModels/ServiceLevelObjective.js.map +1 -1
- package/build/dist/Models/DatabaseModels/ServiceLevelObjectiveBurnRateRule.js +798 -96
- package/build/dist/Models/DatabaseModels/ServiceLevelObjectiveBurnRateRule.js.map +1 -1
- package/build/dist/Models/DatabaseModels/ServiceLevelObjectiveFeed.js +596 -0
- package/build/dist/Models/DatabaseModels/ServiceLevelObjectiveFeed.js.map +1 -0
- package/build/dist/Models/DatabaseModels/ServiceLevelObjectiveMonitorRule.js +590 -0
- package/build/dist/Models/DatabaseModels/ServiceLevelObjectiveMonitorRule.js.map +1 -0
- package/build/dist/Models/DatabaseModels/ServiceLevelObjectiveOwnerTeam.js +16 -0
- package/build/dist/Models/DatabaseModels/ServiceLevelObjectiveOwnerTeam.js.map +1 -1
- package/build/dist/Models/DatabaseModels/ServiceLevelObjectiveOwnerUser.js +16 -0
- package/build/dist/Models/DatabaseModels/ServiceLevelObjectiveOwnerUser.js.map +1 -1
- package/build/dist/Models/DatabaseModels/StatusPageAnnouncement.js +75 -0
- package/build/dist/Models/DatabaseModels/StatusPageAnnouncement.js.map +1 -1
- package/build/dist/Models/DatabaseModels/ThreatIntelFeed.js +1 -1
- package/build/dist/Server/API/BaseAPI.js +14 -0
- package/build/dist/Server/API/BaseAPI.js.map +1 -1
- package/build/dist/Server/API/BillingInvoiceAPI.js +233 -19
- package/build/dist/Server/API/BillingInvoiceAPI.js.map +1 -1
- package/build/dist/Server/API/BillingPaymentMethodAPI.js +86 -5
- package/build/dist/Server/API/BillingPaymentMethodAPI.js.map +1 -1
- package/build/dist/Server/API/DashboardAPI.js +72 -2
- package/build/dist/Server/API/DashboardAPI.js.map +1 -1
- package/build/dist/Server/API/SecurityEventConnectionAPI.js +102 -10
- package/build/dist/Server/API/SecurityEventConnectionAPI.js.map +1 -1
- package/build/dist/Server/API/StatusPageAPI.js +236 -154
- package/build/dist/Server/API/StatusPageAPI.js.map +1 -1
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1792800000000-AddNetworkDeviceDiagnostic.js +34 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1792800000000-AddNetworkDeviceDiagnostic.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1792900000000-AddNetworkDeviceDnsNameAndShortDeviceNames.js +24 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1792900000000-AddNetworkDeviceDnsNameAndShortDeviceNames.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1793000000000-AddNetbiosLookupToNetworkDeviceDiscoveryScan.js +21 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1793000000000-AddNetbiosLookupToNetworkDeviceDiscoveryScan.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1793100000000-SloProductOverhaul.js +207 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1793100000000-SloProductOverhaul.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1793200000000-BackfillSloMonitorRulesAndAffectedResources.js +72 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1793200000000-BackfillSloMonitorRulesAndAffectedResources.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1793300000000-AddDataResidencyToProject.js +20 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1793300000000-AddDataResidencyToProject.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1793400000000-AddSubscriberUpdateNotificationStatus.js +46 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1793400000000-AddSubscriberUpdateNotificationStatus.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +14 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Services/AlertEpisodeLabelRuleEngineService.js +112 -56
- package/build/dist/Server/Services/AlertEpisodeLabelRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/AlertEpisodeOwnerRuleEngineService.js +167 -68
- package/build/dist/Server/Services/AlertEpisodeOwnerRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/AlertEpisodePrivacyRuleEngineService.js +87 -26
- package/build/dist/Server/Services/AlertEpisodePrivacyRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/AlertLabelRuleEngineService.js +270 -203
- package/build/dist/Server/Services/AlertLabelRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/AlertOwnerRuleEngineService.js +498 -354
- package/build/dist/Server/Services/AlertOwnerRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/AlertPrivacyRuleEngineService.js +97 -34
- package/build/dist/Server/Services/AlertPrivacyRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/AlertService.js +91 -8
- package/build/dist/Server/Services/AlertService.js.map +1 -1
- package/build/dist/Server/Services/AuditLogService.js +408 -44
- package/build/dist/Server/Services/AuditLogService.js.map +1 -1
- package/build/dist/Server/Services/BillingInvoiceService.js +94 -85
- package/build/dist/Server/Services/BillingInvoiceService.js.map +1 -1
- package/build/dist/Server/Services/BillingService.js +406 -14
- package/build/dist/Server/Services/BillingService.js.map +1 -1
- package/build/dist/Server/Services/CephClusterLabelRuleEngineService.js +141 -92
- package/build/dist/Server/Services/CephClusterLabelRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/CephClusterOwnerRuleEngineService.js +189 -101
- package/build/dist/Server/Services/CephClusterOwnerRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/CloudResourceLabelRuleEngineService.js +135 -86
- package/build/dist/Server/Services/CloudResourceLabelRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/CloudResourceOwnerRuleEngineService.js +189 -100
- package/build/dist/Server/Services/CloudResourceOwnerRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/DashboardLabelRuleEngineService.js +117 -69
- package/build/dist/Server/Services/DashboardLabelRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/DashboardOwnerRuleEngineService.js +171 -83
- package/build/dist/Server/Services/DashboardOwnerRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/DatabaseService.js +125 -18
- package/build/dist/Server/Services/DatabaseService.js.map +1 -1
- package/build/dist/Server/Services/DockerHostLabelRuleEngineService.js +141 -92
- package/build/dist/Server/Services/DockerHostLabelRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/DockerHostOwnerRuleEngineService.js +189 -101
- package/build/dist/Server/Services/DockerHostOwnerRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/DockerSwarmClusterLabelRuleEngineService.js +145 -91
- package/build/dist/Server/Services/DockerSwarmClusterLabelRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/DockerSwarmClusterOwnerRuleEngineService.js +191 -101
- package/build/dist/Server/Services/DockerSwarmClusterOwnerRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/HostLabelRuleEngineService.js +141 -92
- package/build/dist/Server/Services/HostLabelRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/HostOwnerRuleEngineService.js +190 -102
- package/build/dist/Server/Services/HostOwnerRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/IncidentEpisodeLabelRuleEngineService.js +112 -56
- package/build/dist/Server/Services/IncidentEpisodeLabelRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/IncidentEpisodeOwnerRuleEngineService.js +220 -63
- package/build/dist/Server/Services/IncidentEpisodeOwnerRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/IncidentEpisodePrivacyRuleEngineService.js +87 -26
- package/build/dist/Server/Services/IncidentEpisodePrivacyRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/IncidentEpisodePublicNoteService.js +24 -0
- package/build/dist/Server/Services/IncidentEpisodePublicNoteService.js.map +1 -1
- package/build/dist/Server/Services/IncidentLabelRuleEngineService.js +258 -192
- package/build/dist/Server/Services/IncidentLabelRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/IncidentOwnerRuleEngineService.js +519 -376
- package/build/dist/Server/Services/IncidentOwnerRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/IncidentPrivacyRuleEngineService.js +95 -32
- package/build/dist/Server/Services/IncidentPrivacyRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/IncidentPublicNoteService.js +24 -0
- package/build/dist/Server/Services/IncidentPublicNoteService.js.map +1 -1
- package/build/dist/Server/Services/IncidentService.js +90 -5
- package/build/dist/Server/Services/IncidentService.js.map +1 -1
- package/build/dist/Server/Services/IncomingCallPolicyLabelRuleEngineService.js +113 -65
- package/build/dist/Server/Services/IncomingCallPolicyLabelRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/IncomingCallPolicyOwnerRuleEngineService.js +171 -83
- package/build/dist/Server/Services/IncomingCallPolicyOwnerRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/Index.js +6 -4
- package/build/dist/Server/Services/Index.js.map +1 -1
- package/build/dist/Server/Services/IoTFleetLabelRuleEngineService.js +117 -69
- package/build/dist/Server/Services/IoTFleetLabelRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/IoTFleetOwnerRuleEngineService.js +171 -83
- package/build/dist/Server/Services/IoTFleetOwnerRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/KubernetesClusterLabelRuleEngineService.js +145 -91
- package/build/dist/Server/Services/KubernetesClusterLabelRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/KubernetesClusterOwnerRuleEngineService.js +191 -101
- package/build/dist/Server/Services/KubernetesClusterOwnerRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/LabelService.js +20 -25
- package/build/dist/Server/Services/LabelService.js.map +1 -1
- package/build/dist/Server/Services/MonitorLabelRuleEngineService.js +123 -77
- package/build/dist/Server/Services/MonitorLabelRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/MonitorOwnerRuleEngineService.js +167 -82
- package/build/dist/Server/Services/MonitorOwnerRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/MonitorProbeService.js +18 -2
- package/build/dist/Server/Services/MonitorProbeService.js.map +1 -1
- package/build/dist/Server/Services/MonitorService.js +11 -9
- package/build/dist/Server/Services/MonitorService.js.map +1 -1
- package/build/dist/Server/Services/NetworkDeviceAutoImportRuleEngineService.js +287 -5
- package/build/dist/Server/Services/NetworkDeviceAutoImportRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/NetworkDeviceDiagnosticService.js +333 -0
- package/build/dist/Server/Services/NetworkDeviceDiagnosticService.js.map +1 -0
- package/build/dist/Server/Services/NetworkDeviceLabelRuleEngineService.js +117 -69
- package/build/dist/Server/Services/NetworkDeviceLabelRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/NetworkDeviceOwnerRuleEngineService.js +171 -83
- package/build/dist/Server/Services/NetworkDeviceOwnerRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/NetworkDeviceService.js +36 -2
- package/build/dist/Server/Services/NetworkDeviceService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyLabelRuleEngineService.js +117 -64
- package/build/dist/Server/Services/OnCallDutyPolicyLabelRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyOwnerRuleEngineService.js +173 -83
- package/build/dist/Server/Services/OnCallDutyPolicyOwnerRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyScheduleLabelRuleEngineService.js +116 -65
- package/build/dist/Server/Services/OnCallDutyPolicyScheduleLabelRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyScheduleOwnerRuleEngineService.js +171 -83
- package/build/dist/Server/Services/OnCallDutyPolicyScheduleOwnerRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/PodmanHostLabelRuleEngineService.js +141 -92
- package/build/dist/Server/Services/PodmanHostLabelRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/PodmanHostOwnerRuleEngineService.js +189 -101
- package/build/dist/Server/Services/PodmanHostOwnerRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/ProjectService.js +82 -10
- package/build/dist/Server/Services/ProjectService.js.map +1 -1
- package/build/dist/Server/Services/ProxmoxClusterLabelRuleEngineService.js +141 -92
- package/build/dist/Server/Services/ProxmoxClusterLabelRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/ProxmoxClusterOwnerRuleEngineService.js +189 -101
- package/build/dist/Server/Services/ProxmoxClusterOwnerRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/RumApplicationLabelRuleEngineService.js +111 -63
- package/build/dist/Server/Services/RumApplicationLabelRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/RumApplicationOwnerRuleEngineService.js +161 -77
- package/build/dist/Server/Services/RumApplicationOwnerRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/RunbookLabelRuleEngineService.js +117 -69
- package/build/dist/Server/Services/RunbookLabelRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/RunbookOwnerRuleEngineService.js +171 -83
- package/build/dist/Server/Services/RunbookOwnerRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/ScheduledMaintenanceLabelRuleEngineService.js +280 -209
- package/build/dist/Server/Services/ScheduledMaintenanceLabelRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/ScheduledMaintenanceOwnerRuleEngineService.js +521 -376
- package/build/dist/Server/Services/ScheduledMaintenanceOwnerRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/ScheduledMaintenancePublicNoteService.js +24 -0
- package/build/dist/Server/Services/ScheduledMaintenancePublicNoteService.js.map +1 -1
- package/build/dist/Server/Services/ScheduledMaintenanceService.js +24 -8
- package/build/dist/Server/Services/ScheduledMaintenanceService.js.map +1 -1
- package/build/dist/Server/Services/SecurityEventConnectionService.js +43 -3
- package/build/dist/Server/Services/SecurityEventConnectionService.js.map +1 -1
- package/build/dist/Server/Services/ServerlessFunctionLabelRuleEngineService.js +115 -62
- package/build/dist/Server/Services/ServerlessFunctionLabelRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/ServerlessFunctionOwnerRuleEngineService.js +163 -77
- package/build/dist/Server/Services/ServerlessFunctionOwnerRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/ServiceLabelRuleEngineService.js +141 -92
- package/build/dist/Server/Services/ServiceLabelRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/ServiceLevelObjectiveBurnRateRuleService.js +769 -18
- package/build/dist/Server/Services/ServiceLevelObjectiveBurnRateRuleService.js.map +1 -1
- package/build/dist/Server/Services/ServiceLevelObjectiveFeedService.js +96 -0
- package/build/dist/Server/Services/ServiceLevelObjectiveFeedService.js.map +1 -0
- package/build/dist/Server/Services/ServiceLevelObjectiveMonitorRuleEngineService.js +614 -87
- package/build/dist/Server/Services/ServiceLevelObjectiveMonitorRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/ServiceLevelObjectiveMonitorRuleService.js +844 -0
- package/build/dist/Server/Services/ServiceLevelObjectiveMonitorRuleService.js.map +1 -0
- package/build/dist/Server/Services/ServiceLevelObjectiveOwnerTeamService.js +207 -1
- package/build/dist/Server/Services/ServiceLevelObjectiveOwnerTeamService.js.map +1 -1
- package/build/dist/Server/Services/ServiceLevelObjectiveOwnerUserService.js +221 -1
- package/build/dist/Server/Services/ServiceLevelObjectiveOwnerUserService.js.map +1 -1
- package/build/dist/Server/Services/ServiceLevelObjectiveService.js +997 -50
- package/build/dist/Server/Services/ServiceLevelObjectiveService.js.map +1 -1
- package/build/dist/Server/Services/ServiceOwnerRuleEngineService.js +191 -102
- package/build/dist/Server/Services/ServiceOwnerRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/StatusPageAnnouncementService.js +12 -0
- package/build/dist/Server/Services/StatusPageAnnouncementService.js.map +1 -1
- package/build/dist/Server/Services/StatusPageLabelRuleEngineService.js +118 -70
- package/build/dist/Server/Services/StatusPageLabelRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/StatusPageOwnerRuleEngineService.js +158 -76
- package/build/dist/Server/Services/StatusPageOwnerRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/StatusPageSubscriberNotificationTemplateService.js +19 -215
- package/build/dist/Server/Services/StatusPageSubscriberNotificationTemplateService.js.map +1 -1
- package/build/dist/Server/Services/StatusPageSubscriberService.js +6 -0
- package/build/dist/Server/Services/StatusPageSubscriberService.js.map +1 -1
- package/build/dist/Server/Services/TelemetryUsageBillingService.js +27 -5
- package/build/dist/Server/Services/TelemetryUsageBillingService.js.map +1 -1
- package/build/dist/Server/Services/ThreatIntelFeedService.js +1 -1
- package/build/dist/Server/Services/VMwareVCenterLabelRuleEngineService.js +141 -92
- package/build/dist/Server/Services/VMwareVCenterLabelRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/VMwareVCenterOwnerRuleEngineService.js +189 -101
- package/build/dist/Server/Services/VMwareVCenterOwnerRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/WorkflowLabelRuleEngineService.js +117 -69
- package/build/dist/Server/Services/WorkflowLabelRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/WorkflowOwnerRuleEngineService.js +171 -83
- package/build/dist/Server/Services/WorkflowOwnerRuleEngineService.js.map +1 -1
- package/build/dist/Server/Utils/AI/AlertAIContextBuilder.js +17 -0
- package/build/dist/Server/Utils/AI/AlertAIContextBuilder.js.map +1 -1
- package/build/dist/Server/Utils/AI/IncidentAIContextBuilder.js +31 -0
- package/build/dist/Server/Utils/AI/IncidentAIContextBuilder.js.map +1 -1
- package/build/dist/Server/Utils/AI/Toolbox/AlertTools.js +24 -1
- package/build/dist/Server/Utils/AI/Toolbox/AlertTools.js.map +1 -1
- package/build/dist/Server/Utils/AI/Toolbox/IncidentTools.js +21 -1
- package/build/dist/Server/Utils/AI/Toolbox/IncidentTools.js.map +1 -1
- package/build/dist/Server/Utils/AI/Toolbox/SloTools.js +337 -53
- package/build/dist/Server/Utils/AI/Toolbox/SloTools.js.map +1 -1
- package/build/dist/Server/Utils/Dashboard/PublicDashboardResourceListPolicy.js +108 -15
- package/build/dist/Server/Utils/Dashboard/PublicDashboardResourceListPolicy.js.map +1 -1
- package/build/dist/Server/Utils/Dashboard/PublicDashboardSloHistoryPolicy.js +2 -2
- package/build/dist/Server/Utils/Dashboard/PublicDashboardSloHistoryPolicy.js.map +1 -1
- package/build/dist/Server/Utils/Dashboard/PublicDashboardSloWidget.js +115 -6
- package/build/dist/Server/Utils/Dashboard/PublicDashboardSloWidget.js.map +1 -1
- package/build/dist/Server/Utils/Database/ProjectScopedReferenceValidator.js +13 -0
- package/build/dist/Server/Utils/Database/ProjectScopedReferenceValidator.js.map +1 -1
- package/build/dist/Server/Utils/Database/RelationValueUtil.js +82 -0
- package/build/dist/Server/Utils/Database/RelationValueUtil.js.map +1 -0
- package/build/dist/Server/Utils/Monitor/Criteria/CompareCriteria.js +10 -6
- package/build/dist/Server/Utils/Monitor/Criteria/CompareCriteria.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/Criteria/EvaluateOverTime.js +17 -21
- package/build/dist/Server/Utils/Monitor/Criteria/EvaluateOverTime.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaExpectationBuilder.js +5 -4
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaExpectationBuilder.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorStepsProjectValidator.js +50 -10
- package/build/dist/Server/Utils/Monitor/MonitorStepsProjectValidator.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/NetworkDeviceHydrationUtil.js +13 -1
- package/build/dist/Server/Utils/Monitor/NetworkDeviceHydrationUtil.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/NetworkDeviceMetricUtil.js +6 -10
- package/build/dist/Server/Utils/Monitor/NetworkDeviceMetricUtil.js.map +1 -1
- package/build/dist/Server/Utils/Rules/MonitorRulePatternValidator.js +34 -0
- package/build/dist/Server/Utils/Rules/MonitorRulePatternValidator.js.map +1 -0
- package/build/dist/Server/Utils/Rules/OwnerRuleAssignment.js +69 -0
- package/build/dist/Server/Utils/Rules/OwnerRuleAssignment.js.map +1 -0
- package/build/dist/Server/Utils/Rules/RuleRun/RuleApplication.js +25 -0
- package/build/dist/Server/Utils/Rules/RuleRun/RuleApplication.js.map +1 -0
- package/build/dist/Server/Utils/Rules/RuleRun/RuleRunPermission.js +128 -0
- package/build/dist/Server/Utils/Rules/RuleRun/RuleRunPermission.js.map +1 -0
- package/build/dist/Server/Utils/Rules/RuleRun/RuleRunRegistry.js +746 -0
- package/build/dist/Server/Utils/Rules/RuleRun/RuleRunRegistry.js.map +1 -0
- package/build/dist/Server/Utils/Rules/RuleRun/RuleRunner.js +221 -0
- package/build/dist/Server/Utils/Rules/RuleRun/RuleRunner.js.map +1 -0
- package/build/dist/Server/Utils/SecurityEvent/ConnectorErrorMessage.js +3 -2
- package/build/dist/Server/Utils/SecurityEvent/ConnectorErrorMessage.js.map +1 -1
- package/build/dist/Server/Utils/SecurityEvent/Connectors/ConnectorPlatformHealth.js +6 -4
- package/build/dist/Server/Utils/SecurityEvent/Connectors/ConnectorPlatformHealth.js.map +1 -1
- package/build/dist/Server/Utils/SecurityEvent/{GoogleSecOps → Connectors/GoogleSecOps}/GoogleSecOpsClient.js +174 -14
- package/build/dist/Server/Utils/SecurityEvent/Connectors/GoogleSecOps/GoogleSecOpsClient.js.map +1 -0
- package/build/dist/Server/Utils/SecurityEvent/Connectors/GoogleSecOps/GoogleSecOpsConnector.js +1417 -0
- package/build/dist/Server/Utils/SecurityEvent/Connectors/GoogleSecOps/GoogleSecOpsConnector.js.map +1 -0
- package/build/dist/Server/Utils/SecurityEvent/Connectors/SecurityEventConnectionPoller.js +138 -18
- package/build/dist/Server/Utils/SecurityEvent/Connectors/SecurityEventConnectionPoller.js.map +1 -1
- package/build/dist/Server/Utils/SecurityEvent/Connectors/SecurityEventConnectionRunExecutor.js +1 -2
- package/build/dist/Server/Utils/SecurityEvent/Connectors/SecurityEventConnectionRunExecutor.js.map +1 -1
- package/build/dist/Server/Utils/SecurityEvent/Connectors/SecurityEventConnectionTester.js +23 -18
- package/build/dist/Server/Utils/SecurityEvent/Connectors/SecurityEventConnectionTester.js.map +1 -1
- package/build/dist/Server/Utils/SecurityEvent/Connectors/SecurityEventConnectorRegistry.js +2 -0
- package/build/dist/Server/Utils/SecurityEvent/Connectors/SecurityEventConnectorRegistry.js.map +1 -1
- package/build/dist/Server/Utils/SecurityEvent/Connectors/Types.js +95 -0
- package/build/dist/Server/Utils/SecurityEvent/Connectors/Types.js.map +1 -1
- package/build/dist/Server/Utils/SecurityEvent/DetectionRuleEvaluator.js +1 -1
- package/build/dist/Server/Utils/SecurityEvent/SecurityEventDedupe.js +3 -3
- package/build/dist/Server/Utils/SecurityEvent/ThreatIntel/ThreatIntelFeedPoller.js +2 -2
- package/build/dist/Server/Utils/SessionReplay/SessionReplayReadService.js +118 -40
- package/build/dist/Server/Utils/SessionReplay/SessionReplayReadService.js.map +1 -1
- package/build/dist/Server/Utils/Slo/SloFeedUtil.js +150 -0
- package/build/dist/Server/Utils/Slo/SloFeedUtil.js.map +1 -0
- package/build/dist/Server/Utils/Slo/SloLegacyMonitorLabelAdoption.js +136 -0
- package/build/dist/Server/Utils/Slo/SloLegacyMonitorLabelAdoption.js.map +1 -0
- package/build/dist/Server/Utils/Slo/SloMetricUtil.js +269 -0
- package/build/dist/Server/Utils/Slo/SloMetricUtil.js.map +1 -0
- package/build/dist/Server/Utils/Slo/SloOwnerReferenceValidator.js +134 -0
- package/build/dist/Server/Utils/Slo/SloOwnerReferenceValidator.js.map +1 -0
- package/build/dist/Server/Utils/Slo/SloRecordReferenceValidator.js +137 -0
- package/build/dist/Server/Utils/Slo/SloRecordReferenceValidator.js.map +1 -0
- package/build/dist/Server/Utils/StatusPage/MonitorRulePatternValidator.js +6 -26
- package/build/dist/Server/Utils/StatusPage/MonitorRulePatternValidator.js.map +1 -1
- package/build/dist/Server/Utils/StatusPageResource.js +31 -5
- package/build/dist/Server/Utils/StatusPageResource.js.map +1 -1
- package/build/dist/Types/Billing/SubscriptionStatus.js +37 -3
- package/build/dist/Types/Billing/SubscriptionStatus.js.map +1 -1
- package/build/dist/Types/Dashboard/DashboardComponentType.js +1 -0
- package/build/dist/Types/Dashboard/DashboardComponentType.js.map +1 -1
- package/build/dist/Types/Dashboard/DashboardComponents/ComponentArgument.js +5 -0
- package/build/dist/Types/Dashboard/DashboardComponents/ComponentArgument.js.map +1 -1
- package/build/dist/Types/Dashboard/DashboardComponents/DashboardSloListComponent.js +2 -0
- package/build/dist/Types/Dashboard/DashboardComponents/DashboardSloListComponent.js.map +1 -0
- package/build/dist/Types/Dashboard/DashboardTemplates.js +275 -286
- package/build/dist/Types/Dashboard/DashboardTemplates.js.map +1 -1
- package/build/dist/Types/Database/EnableAuditLog.js +19 -1
- package/build/dist/Types/Database/EnableAuditLog.js.map +1 -1
- package/build/dist/Types/Email/EmailTemplateType.js +4 -0
- package/build/dist/Types/Email/EmailTemplateType.js.map +1 -1
- package/build/dist/Types/Monitor/CriteriaFilter.js +45 -6
- package/build/dist/Types/Monitor/CriteriaFilter.js.map +1 -1
- package/build/dist/Types/Monitor/MonitorStep.js +2 -0
- package/build/dist/Types/Monitor/MonitorStep.js.map +1 -1
- package/build/dist/Types/Monitor/MonitorStepDnsMonitor.js +3 -1
- package/build/dist/Types/Monitor/MonitorStepDnsMonitor.js.map +1 -1
- package/build/dist/Types/Monitor/MonitorStepDnssecMonitor.js +3 -1
- package/build/dist/Types/Monitor/MonitorStepDnssecMonitor.js.map +1 -1
- package/build/dist/Types/Monitor/MonitorStepDomainMonitor.js +3 -1
- package/build/dist/Types/Monitor/MonitorStepDomainMonitor.js.map +1 -1
- package/build/dist/Types/Monitor/MonitorStepExternalStatusPageMonitor.js +3 -1
- package/build/dist/Types/Monitor/MonitorStepExternalStatusPageMonitor.js.map +1 -1
- package/build/dist/Types/Monitor/MonitorStepRetries.js +47 -0
- package/build/dist/Types/Monitor/MonitorStepRetries.js.map +1 -0
- package/build/dist/Types/Monitor/MonitorStepSnmpMonitor.js +3 -1
- package/build/dist/Types/Monitor/MonitorStepSnmpMonitor.js.map +1 -1
- package/build/dist/Types/NetworkDevice/NetworkDeviceDiagnosticResult.js +29 -0
- package/build/dist/Types/NetworkDevice/NetworkDeviceDiagnosticResult.js.map +1 -0
- package/build/dist/Types/NetworkDevice/NetworkDeviceDiagnosticStatus.js +37 -0
- package/build/dist/Types/NetworkDevice/NetworkDeviceDiagnosticStatus.js.map +1 -0
- package/build/dist/Types/NetworkDevice/NetworkDeviceDiagnosticType.js +42 -0
- package/build/dist/Types/NetworkDevice/NetworkDeviceDiagnosticType.js.map +1 -0
- package/build/dist/Types/NetworkDevice/NetworkDevicePingMetricNames.js +20 -0
- package/build/dist/Types/NetworkDevice/NetworkDevicePingMetricNames.js.map +1 -0
- package/build/dist/Types/Permission.js +114 -0
- package/build/dist/Types/Permission.js.map +1 -1
- package/build/dist/Types/Rules/RuleCriteriaFieldRegistry.js +5 -0
- package/build/dist/Types/Rules/RuleCriteriaFieldRegistry.js.map +1 -1
- package/build/dist/Types/Rules/RuleRun.js +267 -0
- package/build/dist/Types/Rules/RuleRun.js.map +1 -0
- package/build/dist/Types/Rum/SessionReplayApi.js.map +1 -1
- package/build/dist/Types/SecurityEvent/Connectors/ConnectorDiagnostics.js.map +1 -1
- package/build/dist/Types/SecurityEvent/Connectors/SecurityEventConnectionDiagnostics.js +16 -1
- package/build/dist/Types/SecurityEvent/Connectors/SecurityEventConnectionDiagnostics.js.map +1 -1
- package/build/dist/Types/SecurityEvent/Connectors/SecurityEventConnectorCatalog.js +65 -0
- package/build/dist/Types/SecurityEvent/Connectors/SecurityEventConnectorCatalog.js.map +1 -1
- package/build/dist/Types/SecurityEvent/Connectors/SecurityEventConnectorProvider.js +6 -2
- package/build/dist/Types/SecurityEvent/Connectors/SecurityEventConnectorProvider.js.map +1 -1
- package/build/dist/Types/ServiceLevelObjective/SloHistoryMetricName.js +26 -0
- package/build/dist/Types/ServiceLevelObjective/SloHistoryMetricName.js.map +1 -0
- package/build/dist/Types/ServiceLevelObjective/SloMetricType.js +45 -0
- package/build/dist/Types/ServiceLevelObjective/SloMetricType.js.map +1 -0
- package/build/dist/Types/StatusPage/StatusPageSubscriberNotificationEventType.js +4 -0
- package/build/dist/Types/StatusPage/StatusPageSubscriberNotificationEventType.js.map +1 -1
- package/build/dist/Types/StatusPage/SubscriberNotificationTemplateVariables.js +295 -0
- package/build/dist/Types/StatusPage/SubscriberNotificationTemplateVariables.js.map +1 -0
- package/build/dist/Types/StatusPage/SubscriberNotificationTrigger.js +13 -0
- package/build/dist/Types/StatusPage/SubscriberNotificationTrigger.js.map +1 -0
- package/build/dist/Types/StatusPage/SubscriberUpdateNotification.js +67 -0
- package/build/dist/Types/StatusPage/SubscriberUpdateNotification.js.map +1 -0
- package/build/dist/Types/Telemetry/LockedFilterDetail.js +7 -7
- package/build/dist/Types/Telemetry/ServiceType.js +7 -0
- package/build/dist/Types/Telemetry/ServiceType.js.map +1 -1
- package/build/dist/UI/Components/AlertBanner/AlertBanner.js +48 -19
- package/build/dist/UI/Components/AlertBanner/AlertBanner.js.map +1 -1
- package/build/dist/UI/Components/BulkUpdate/BulkArchiveActions.js +10 -2
- package/build/dist/UI/Components/BulkUpdate/BulkArchiveActions.js.map +1 -1
- package/build/dist/UI/Components/Detail/Detail.js +12 -3
- package/build/dist/UI/Components/Detail/Detail.js.map +1 -1
- package/build/dist/UI/Components/Dropdown/Dropdown.js +33 -5
- package/build/dist/UI/Components/Dropdown/Dropdown.js.map +1 -1
- package/build/dist/UI/Components/EmptyState/EmptyState.js +3 -3
- package/build/dist/UI/Components/EmptyState/EmptyState.js.map +1 -1
- package/build/dist/UI/Components/EmptyState/EmptyStateGuideLinks.js +47 -0
- package/build/dist/UI/Components/EmptyState/EmptyStateGuideLinks.js.map +1 -0
- package/build/dist/UI/Components/Forms/ModelForm.js +6 -5
- package/build/dist/UI/Components/Forms/ModelForm.js.map +1 -1
- package/build/dist/UI/Components/LabelRule/LabelRuleTable.js +6 -2
- package/build/dist/UI/Components/LabelRule/LabelRuleTable.js.map +1 -1
- package/build/dist/UI/Components/LogsViewer/LogsViewer.js +1 -1
- package/build/dist/UI/Components/LogsViewer/LogsViewer.js.map +1 -1
- package/build/dist/UI/Components/LogsViewer/components/ActiveFilterChips.js +0 -2
- package/build/dist/UI/Components/LogsViewer/components/ActiveFilterChips.js.map +1 -1
- package/build/dist/UI/Components/MoreMenu/MoreMenu.js +3 -1
- package/build/dist/UI/Components/MoreMenu/MoreMenu.js.map +1 -1
- package/build/dist/UI/Components/RuleRun/RuleDetailFields.js +226 -0
- package/build/dist/UI/Components/RuleRun/RuleDetailFields.js.map +1 -0
- package/build/dist/UI/Components/RuleRun/RuleTable.js +97 -0
- package/build/dist/UI/Components/RuleRun/RuleTable.js.map +1 -0
- package/build/dist/UI/Components/RuleRun/RuleView.js +83 -0
- package/build/dist/UI/Components/RuleRun/RuleView.js.map +1 -0
- package/build/dist/UI/Components/RuleRun/RunRuleNowModal.js +74 -0
- package/build/dist/UI/Components/RuleRun/RunRuleNowModal.js.map +1 -0
- package/build/dist/UI/Components/RuleRun/RunRulesBulkAction.js +78 -0
- package/build/dist/UI/Components/RuleRun/RunRulesBulkAction.js.map +1 -0
- package/build/dist/UI/Components/TelemetryViewer/TelemetryViewer.js +1 -1
- package/build/dist/UI/Components/TelemetryViewer/TelemetryViewer.js.map +1 -1
- package/build/dist/UI/Components/TelemetryViewer/components/LockedFilterChip.js +24 -50
- package/build/dist/UI/Components/TelemetryViewer/components/LockedFilterChip.js.map +1 -1
- package/build/dist/UI/Components/TelemetryViewer/components/TelemetryActiveFilterChips.js +0 -4
- package/build/dist/UI/Components/TelemetryViewer/components/TelemetryActiveFilterChips.js.map +1 -1
- package/build/dist/UI/Utils/Rules/RuleRunClient.js +98 -0
- package/build/dist/UI/Utils/Rules/RuleRunClient.js.map +1 -0
- package/build/dist/UI/Utils/Telemetry/TelemetryEntityNames.js +8 -0
- package/build/dist/UI/Utils/Telemetry/TelemetryEntityNames.js.map +1 -1
- package/build/dist/Utils/Dashboard/Components/DashboardSloComponent.js +16 -2
- package/build/dist/Utils/Dashboard/Components/DashboardSloComponent.js.map +1 -1
- package/build/dist/Utils/Dashboard/Components/DashboardSloListComponent.js +94 -0
- package/build/dist/Utils/Dashboard/Components/DashboardSloListComponent.js.map +1 -0
- package/build/dist/Utils/Dashboard/Components/Index.js +4 -0
- package/build/dist/Utils/Dashboard/Components/Index.js.map +1 -1
- package/build/dist/Utils/Dashboard/SloWidgetSource.js +125 -0
- package/build/dist/Utils/Dashboard/SloWidgetSource.js.map +1 -0
- package/build/dist/Utils/Markdown/MarkdownEscape.js +49 -0
- package/build/dist/Utils/Markdown/MarkdownEscape.js.map +1 -0
- package/build/dist/Utils/NetworkDiscovery/DiscoveredDeviceBuilder.js +112 -34
- package/build/dist/Utils/NetworkDiscovery/DiscoveredDeviceBuilder.js.map +1 -1
- package/build/dist/Utils/NetworkDiscovery/DiscoveredHostUtil.js +22 -0
- package/build/dist/Utils/NetworkDiscovery/DiscoveredHostUtil.js.map +1 -1
- package/build/dist/Utils/NetworkDiscovery/NetbiosNameUtil.js +129 -0
- package/build/dist/Utils/NetworkDiscovery/NetbiosNameUtil.js.map +1 -0
- package/build/dist/Utils/NetworkDiscovery/RunImportedDeviceNaming.js +255 -0
- package/build/dist/Utils/NetworkDiscovery/RunImportedDeviceNaming.js.map +1 -0
- package/build/dist/Utils/NetworkDiscovery/ShortDeviceNamePlanner.js +184 -0
- package/build/dist/Utils/NetworkDiscovery/ShortDeviceNamePlanner.js.map +1 -0
- package/build/dist/Utils/NetworkDiscovery/ShortHostnameUtil.js +79 -0
- package/build/dist/Utils/NetworkDiscovery/ShortHostnameUtil.js.map +1 -0
- package/build/dist/Utils/NetworkSite/CidrMatchUtil.js +21 -12
- package/build/dist/Utils/NetworkSite/CidrMatchUtil.js.map +1 -1
- package/build/dist/Utils/Project/DataResidency.js +51 -0
- package/build/dist/Utils/Project/DataResidency.js.map +1 -0
- package/build/dist/Utils/Rules/RuleRunSummary.js +197 -0
- package/build/dist/Utils/Rules/RuleRunSummary.js.map +1 -0
- package/build/dist/Utils/Slo/SloAffectedResourceMarkdown.js +51 -0
- package/build/dist/Utils/Slo/SloAffectedResourceMarkdown.js.map +1 -0
- package/build/dist/Utils/Slo/SloBurnRateTemplate.js +228 -0
- package/build/dist/Utils/Slo/SloBurnRateTemplate.js.map +1 -0
- package/build/dist/Utils/Slo/SloFeedMarkdown.js +934 -0
- package/build/dist/Utils/Slo/SloFeedMarkdown.js.map +1 -0
- package/build/dist/Utils/Slo/SloHealth.js +75 -9
- package/build/dist/Utils/Slo/SloHealth.js.map +1 -1
- package/build/dist/Utils/Slo/SloListWidgetFormat.js +217 -0
- package/build/dist/Utils/Slo/SloListWidgetFormat.js.map +1 -0
- package/build/dist/Utils/Slo/SloMetricType.js +212 -0
- package/build/dist/Utils/Slo/SloMetricType.js.map +1 -0
- package/build/dist/Utils/Slo/SloMonitorRuleCriteria.js +216 -0
- package/build/dist/Utils/Slo/SloMonitorRuleCriteria.js.map +1 -0
- package/build/dist/Utils/Slo/SloMonitorStatusSummary.js +129 -0
- package/build/dist/Utils/Slo/SloMonitorStatusSummary.js.map +1 -0
- package/build/dist/Utils/Slo/SloOverviewText.js +110 -0
- package/build/dist/Utils/Slo/SloOverviewText.js.map +1 -0
- package/build/dist/Utils/Slo/SloProjection.js +448 -0
- package/build/dist/Utils/Slo/SloProjection.js.map +1 -0
- package/build/dist/Utils/Slo/SloWidgetFormat.js +4 -2
- package/build/dist/Utils/Slo/SloWidgetFormat.js.map +1 -1
- package/build/dist/Utils/Telemetry/LockedFilterSearch.js +1 -26
- package/build/dist/Utils/Telemetry/LockedFilterSearch.js.map +1 -1
- package/package.json +1 -1
- package/Models/DatabaseModels/GoogleSecOpsConnection.ts +0 -447
- package/Models/DatabaseModels/GoogleSecOpsConnectionRun.ts +0 -263
- package/Server/API/GoogleSecOpsConnectionAPI.ts +0 -320
- package/Server/Services/GoogleSecOpsConnectionRunService.ts +0 -10
- package/Server/Services/GoogleSecOpsConnectionService.ts +0 -116
- package/Server/Utils/SecurityEvent/GoogleSecOps/GoogleSecOpsConnectionTester.ts +0 -777
- package/Server/Utils/SecurityEvent/GoogleSecOps/GoogleSecOpsPoller.ts +0 -1373
- package/Server/Utils/SecurityEvent/GoogleSecOps/GoogleSecOpsRunExecutor.ts +0 -512
- package/Tests/App/Dashboard/GoogleSecOpsConnectionForm.test.tsx +0 -838
- package/Tests/App/Dashboard/GoogleSecOpsConnectionsErrors.test.tsx +0 -441
- package/Tests/App/Dashboard/GoogleSecOpsDiagnostics.test.tsx +0 -1001
- package/Tests/Server/API/GoogleSecOpsConnectionAPI.test.ts +0 -657
- package/Tests/Server/Services/GoogleSecOpsDiagnosticsModel.test.ts +0 -153
- package/Tests/Server/Utils/SecurityEvent/GoogleSecOps/GoogleSecOpsConnectionTester.test.ts +0 -784
- package/Tests/Server/Utils/SecurityEvent/GoogleSecOps/GoogleSecOpsRunExecutor.test.ts +0 -823
- package/Tests/Server/Utils/SecurityEvent/GoogleSecOpsDiagnostics.test.ts +0 -918
- package/Tests/Server/Utils/SecurityEvent/GoogleSecOpsPoller.test.ts +0 -738
- package/Tests/Server/Utils/SecurityEvent/GoogleSecOpsPollerFailureTaxonomy.test.ts +0 -874
- package/Tests/Server/Utils/SecurityEvent/GoogleSecOpsPollerHardening.test.ts +0 -1297
- package/Tests/Server/Utils/SecurityEvent/GoogleSecOpsThreePassPoller.test.ts +0 -1577
- package/Tests/UI/Components/LockedFilterActions.test.tsx +0 -396
- package/Types/SecurityEvent/GoogleSecOpsDiagnostics.ts +0 -111
- package/UI/Components/TelemetryViewer/components/LockedFilterActions.tsx +0 -205
- package/build/dist/Models/DatabaseModels/GoogleSecOpsConnection.js +0 -478
- package/build/dist/Models/DatabaseModels/GoogleSecOpsConnection.js.map +0 -1
- package/build/dist/Models/DatabaseModels/GoogleSecOpsConnectionRun.js +0 -287
- package/build/dist/Models/DatabaseModels/GoogleSecOpsConnectionRun.js.map +0 -1
- package/build/dist/Server/API/GoogleSecOpsConnectionAPI.js +0 -231
- package/build/dist/Server/API/GoogleSecOpsConnectionAPI.js.map +0 -1
- package/build/dist/Server/Services/GoogleSecOpsConnectionRunService.js +0 -9
- package/build/dist/Server/Services/GoogleSecOpsConnectionRunService.js.map +0 -1
- package/build/dist/Server/Services/GoogleSecOpsConnectionService.js +0 -70
- package/build/dist/Server/Services/GoogleSecOpsConnectionService.js.map +0 -1
- package/build/dist/Server/Utils/SecurityEvent/GoogleSecOps/GoogleSecOpsClient.js.map +0 -1
- package/build/dist/Server/Utils/SecurityEvent/GoogleSecOps/GoogleSecOpsConnectionTester.js +0 -537
- package/build/dist/Server/Utils/SecurityEvent/GoogleSecOps/GoogleSecOpsConnectionTester.js.map +0 -1
- package/build/dist/Server/Utils/SecurityEvent/GoogleSecOps/GoogleSecOpsPoller.js +0 -1034
- package/build/dist/Server/Utils/SecurityEvent/GoogleSecOps/GoogleSecOpsPoller.js.map +0 -1
- package/build/dist/Server/Utils/SecurityEvent/GoogleSecOps/GoogleSecOpsRunExecutor.js +0 -410
- package/build/dist/Server/Utils/SecurityEvent/GoogleSecOps/GoogleSecOpsRunExecutor.js.map +0 -1
- package/build/dist/Types/SecurityEvent/GoogleSecOpsDiagnostics.js +0 -2
- package/build/dist/Types/SecurityEvent/GoogleSecOpsDiagnostics.js.map +0 -1
- package/build/dist/UI/Components/TelemetryViewer/components/LockedFilterActions.js +0 -88
- package/build/dist/UI/Components/TelemetryViewer/components/LockedFilterActions.js.map +0 -1
|
@@ -0,0 +1,1634 @@
|
|
|
1
|
+
import getJestMockFunction, { MockFunction } from "../../MockType";
|
|
2
|
+
import {
|
|
3
|
+
BillingService,
|
|
4
|
+
PaymentMethod,
|
|
5
|
+
} from "../../../Server/Services/BillingService";
|
|
6
|
+
import Errors from "../../../Server/Utils/Errors";
|
|
7
|
+
import logger from "../../../Server/Utils/Logger";
|
|
8
|
+
import SubscriptionPlan from "../../../Types/Billing/SubscriptionPlan";
|
|
9
|
+
import BadDataException from "../../../Types/Exception/BadDataException";
|
|
10
|
+
import ServiceUnavailableException from "../../../Types/Exception/ServiceUnavailableException";
|
|
11
|
+
import ObjectID from "../../../Types/ObjectID";
|
|
12
|
+
import Sleep from "../../../Types/Sleep";
|
|
13
|
+
import { getJestSpyOn } from "../../Spy";
|
|
14
|
+
import {
|
|
15
|
+
afterEach,
|
|
16
|
+
beforeEach,
|
|
17
|
+
describe,
|
|
18
|
+
expect,
|
|
19
|
+
it,
|
|
20
|
+
jest,
|
|
21
|
+
} from "@jest/globals";
|
|
22
|
+
import Stripe from "stripe";
|
|
23
|
+
|
|
24
|
+
jest.mock("stripe", () => {
|
|
25
|
+
return jest.fn(() => {
|
|
26
|
+
return {};
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
jest.mock("../../../Server/Services/ProjectService", () => {
|
|
30
|
+
return { __esModule: true, default: {} };
|
|
31
|
+
});
|
|
32
|
+
jest.mock("../../../Server/Services/MailService", () => {
|
|
33
|
+
return { __esModule: true, default: {} };
|
|
34
|
+
});
|
|
35
|
+
jest.mock("../../../Server/Services/PayAsYouGoBillingService", () => {
|
|
36
|
+
return { __esModule: true, default: {} };
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
/*
|
|
40
|
+
* Autopay has to charge the card the customer has as their default today.
|
|
41
|
+
*
|
|
42
|
+
* Production incident this guards against (a customer project): a plan
|
|
43
|
+
* reactivation recreated the project's subscriptions with
|
|
44
|
+
* default_payment_method pinned to the card that was default that day, an
|
|
45
|
+
* India-issued Visa. Stripe charges subscription.default_payment_method ahead
|
|
46
|
+
* of customer.invoice_settings.default_payment_method, so when that card
|
|
47
|
+
* started declining and the customer added a new card that became their
|
|
48
|
+
* default, every renewal kept going to the old card. Nothing in OneUptime ever
|
|
49
|
+
* cleared the pin, adding a card never made it default, and there was no way
|
|
50
|
+
* to choose a default - the project went past_due on a card the customer had
|
|
51
|
+
* already replaced.
|
|
52
|
+
*
|
|
53
|
+
* The ids below are the ones from that incident.
|
|
54
|
+
*/
|
|
55
|
+
const CUSTOMER_ID: string = "cus_stale_card_customer";
|
|
56
|
+
const OTHER_CUSTOMER_ID: string = "cus_someone_else";
|
|
57
|
+
const OLD_CARD_ID: string = "pm_replaced_card";
|
|
58
|
+
const NEW_CARD_ID: string = "pm_new_default_card";
|
|
59
|
+
const METERED_SUBSCRIPTION_ID: string = "sub_pinned_metered";
|
|
60
|
+
const FLAT_FEE_SUBSCRIPTION_ID: string = "sub_flat_fee";
|
|
61
|
+
|
|
62
|
+
type FakeStripe = {
|
|
63
|
+
customers: { retrieve: MockFunction; update: MockFunction };
|
|
64
|
+
subscriptions: {
|
|
65
|
+
list: MockFunction;
|
|
66
|
+
update: MockFunction;
|
|
67
|
+
retrieve: MockFunction;
|
|
68
|
+
create: MockFunction;
|
|
69
|
+
del: MockFunction;
|
|
70
|
+
};
|
|
71
|
+
paymentMethods: {
|
|
72
|
+
list: MockFunction;
|
|
73
|
+
retrieve: MockFunction;
|
|
74
|
+
detach: MockFunction;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
type CustomerFunction = (
|
|
79
|
+
defaultPaymentMethod: string | Partial<Stripe.PaymentMethod> | null,
|
|
80
|
+
) => Partial<Stripe.Customer>;
|
|
81
|
+
|
|
82
|
+
const customerWithDefault: CustomerFunction = (
|
|
83
|
+
defaultPaymentMethod: string | Partial<Stripe.PaymentMethod> | null,
|
|
84
|
+
): Partial<Stripe.Customer> => {
|
|
85
|
+
return {
|
|
86
|
+
id: CUSTOMER_ID,
|
|
87
|
+
object: "customer",
|
|
88
|
+
invoice_settings: {
|
|
89
|
+
custom_fields: null,
|
|
90
|
+
default_payment_method: defaultPaymentMethod as
|
|
91
|
+
| string
|
|
92
|
+
| Stripe.PaymentMethod
|
|
93
|
+
| null,
|
|
94
|
+
footer: null,
|
|
95
|
+
rendering_options: null,
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
type SubscriptionFunction = (options: {
|
|
101
|
+
id: string;
|
|
102
|
+
status?: Stripe.Subscription.Status | undefined;
|
|
103
|
+
defaultPaymentMethod?: string | Partial<Stripe.PaymentMethod> | null;
|
|
104
|
+
defaultSource?: string | null | undefined;
|
|
105
|
+
itemId?: string | undefined;
|
|
106
|
+
}) => Stripe.Subscription;
|
|
107
|
+
|
|
108
|
+
const subscription: SubscriptionFunction = (options: {
|
|
109
|
+
id: string;
|
|
110
|
+
status?: Stripe.Subscription.Status | undefined;
|
|
111
|
+
defaultPaymentMethod?: string | Partial<Stripe.PaymentMethod> | null;
|
|
112
|
+
defaultSource?: string | null | undefined;
|
|
113
|
+
itemId?: string | undefined;
|
|
114
|
+
}): Stripe.Subscription => {
|
|
115
|
+
return {
|
|
116
|
+
id: options.id,
|
|
117
|
+
object: "subscription",
|
|
118
|
+
customer: CUSTOMER_ID,
|
|
119
|
+
status: options.status || "active",
|
|
120
|
+
default_payment_method: (options.defaultPaymentMethod ?? null) as
|
|
121
|
+
| string
|
|
122
|
+
| Stripe.PaymentMethod
|
|
123
|
+
| null,
|
|
124
|
+
default_source: options.defaultSource ?? null,
|
|
125
|
+
trial_end: null,
|
|
126
|
+
items: {
|
|
127
|
+
data: options.itemId ? [{ id: options.itemId }] : [],
|
|
128
|
+
},
|
|
129
|
+
} as unknown as Stripe.Subscription;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
type CardFunction = (
|
|
133
|
+
id: string,
|
|
134
|
+
last4: string,
|
|
135
|
+
customer?: string | Partial<Stripe.Customer> | null,
|
|
136
|
+
) => Partial<Stripe.PaymentMethod>;
|
|
137
|
+
|
|
138
|
+
const card: CardFunction = (
|
|
139
|
+
id: string,
|
|
140
|
+
last4: string,
|
|
141
|
+
customer?: string | Partial<Stripe.Customer> | null,
|
|
142
|
+
): Partial<Stripe.PaymentMethod> => {
|
|
143
|
+
return {
|
|
144
|
+
id: id,
|
|
145
|
+
object: "payment_method",
|
|
146
|
+
type: "card",
|
|
147
|
+
card: { brand: "visa", last4: last4 } as Stripe.PaymentMethod.Card,
|
|
148
|
+
customer: (customer === undefined ? CUSTOMER_ID : customer) as
|
|
149
|
+
| string
|
|
150
|
+
| Stripe.Customer
|
|
151
|
+
| null,
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
type ProviderErrorFunction = (fields: {
|
|
156
|
+
statusCode?: number | undefined;
|
|
157
|
+
type?: string | undefined;
|
|
158
|
+
rawType?: string | undefined;
|
|
159
|
+
code?: string | undefined;
|
|
160
|
+
message?: string | undefined;
|
|
161
|
+
}) => Error;
|
|
162
|
+
|
|
163
|
+
const providerError: ProviderErrorFunction = (fields: {
|
|
164
|
+
statusCode?: number | undefined;
|
|
165
|
+
type?: string | undefined;
|
|
166
|
+
rawType?: string | undefined;
|
|
167
|
+
code?: string | undefined;
|
|
168
|
+
message?: string | undefined;
|
|
169
|
+
}): Error => {
|
|
170
|
+
return Object.assign(new Error(fields.message || "Stripe error"), fields);
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
const resourceMissing: () => Error = (): Error => {
|
|
174
|
+
return providerError({
|
|
175
|
+
statusCode: 404,
|
|
176
|
+
type: "StripeInvalidRequestError",
|
|
177
|
+
rawType: "invalid_request_error",
|
|
178
|
+
code: "resource_missing",
|
|
179
|
+
message: "No such PaymentMethod",
|
|
180
|
+
});
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
type UpdateCall = [string, Stripe.SubscriptionUpdateParams];
|
|
184
|
+
|
|
185
|
+
describe("BillingService - autopay follows the customer's default payment method", () => {
|
|
186
|
+
let service: BillingService;
|
|
187
|
+
let stripe: FakeStripe;
|
|
188
|
+
let loggerError: jest.SpyInstance;
|
|
189
|
+
|
|
190
|
+
beforeEach(() => {
|
|
191
|
+
service = new BillingService();
|
|
192
|
+
|
|
193
|
+
stripe = {
|
|
194
|
+
customers: {
|
|
195
|
+
retrieve: getJestMockFunction().mockResolvedValue(
|
|
196
|
+
customerWithDefault(NEW_CARD_ID),
|
|
197
|
+
),
|
|
198
|
+
update: getJestMockFunction().mockResolvedValue({}),
|
|
199
|
+
},
|
|
200
|
+
subscriptions: {
|
|
201
|
+
list: getJestMockFunction().mockResolvedValue({ data: [] }),
|
|
202
|
+
update: getJestMockFunction().mockResolvedValue({}),
|
|
203
|
+
retrieve: getJestMockFunction(),
|
|
204
|
+
create: getJestMockFunction(),
|
|
205
|
+
del: getJestMockFunction().mockResolvedValue({}),
|
|
206
|
+
},
|
|
207
|
+
paymentMethods: {
|
|
208
|
+
list: getJestMockFunction().mockResolvedValue({ data: [] }),
|
|
209
|
+
retrieve: getJestMockFunction().mockResolvedValue(
|
|
210
|
+
card(NEW_CARD_ID, "1111"),
|
|
211
|
+
),
|
|
212
|
+
detach: getJestMockFunction().mockResolvedValue({}),
|
|
213
|
+
},
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
(service as unknown as { stripe: unknown }).stripe = stripe;
|
|
217
|
+
|
|
218
|
+
getJestSpyOn(service, "isBillingEnabled").mockReturnValue(true);
|
|
219
|
+
getJestSpyOn(Sleep, "sleep").mockResolvedValue(undefined);
|
|
220
|
+
getJestSpyOn(Math, "random").mockReturnValue(0.5);
|
|
221
|
+
getJestSpyOn(logger, "info").mockImplementation(() => {
|
|
222
|
+
return undefined;
|
|
223
|
+
});
|
|
224
|
+
getJestSpyOn(logger, "debug").mockImplementation(() => {
|
|
225
|
+
return undefined;
|
|
226
|
+
});
|
|
227
|
+
loggerError = getJestSpyOn(logger, "error").mockImplementation(() => {
|
|
228
|
+
return undefined;
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
afterEach(() => {
|
|
233
|
+
jest.restoreAllMocks();
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
describe("syncSubscriptionPaymentMethodsWithCustomerDefault", () => {
|
|
237
|
+
it("unpins the pinned metered subscription from the replaced card so autopay charges the new default", async () => {
|
|
238
|
+
stripe.customers.retrieve.mockResolvedValue(
|
|
239
|
+
customerWithDefault(NEW_CARD_ID),
|
|
240
|
+
);
|
|
241
|
+
stripe.subscriptions.list.mockResolvedValue({
|
|
242
|
+
data: [
|
|
243
|
+
subscription({
|
|
244
|
+
id: METERED_SUBSCRIPTION_ID,
|
|
245
|
+
status: "past_due",
|
|
246
|
+
defaultPaymentMethod: OLD_CARD_ID,
|
|
247
|
+
}),
|
|
248
|
+
],
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
await expect(
|
|
252
|
+
service.syncSubscriptionPaymentMethodsWithCustomerDefault(CUSTOMER_ID),
|
|
253
|
+
).resolves.toEqual([METERED_SUBSCRIPTION_ID]);
|
|
254
|
+
|
|
255
|
+
expect(stripe.customers.retrieve).toHaveBeenCalledWith(CUSTOMER_ID);
|
|
256
|
+
expect(stripe.subscriptions.list).toHaveBeenCalledWith({
|
|
257
|
+
customer: CUSTOMER_ID,
|
|
258
|
+
status: "all",
|
|
259
|
+
limit: 100,
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
/*
|
|
263
|
+
* Cleared, not overwritten with the new card: a copy on the
|
|
264
|
+
* subscription is a second place that goes stale the next time the
|
|
265
|
+
* customer changes cards, which is exactly what broke autopay.
|
|
266
|
+
*/
|
|
267
|
+
expect(stripe.subscriptions.update).toHaveBeenCalledTimes(1);
|
|
268
|
+
expect(stripe.subscriptions.update).toHaveBeenCalledWith(
|
|
269
|
+
METERED_SUBSCRIPTION_ID,
|
|
270
|
+
{ default_payment_method: "" },
|
|
271
|
+
);
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
it("leaves a subscription alone when its pin already is the customer default", async () => {
|
|
275
|
+
stripe.subscriptions.list.mockResolvedValue({
|
|
276
|
+
data: [
|
|
277
|
+
subscription({
|
|
278
|
+
id: METERED_SUBSCRIPTION_ID,
|
|
279
|
+
defaultPaymentMethod: NEW_CARD_ID,
|
|
280
|
+
}),
|
|
281
|
+
],
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
await expect(
|
|
285
|
+
service.syncSubscriptionPaymentMethodsWithCustomerDefault(CUSTOMER_ID),
|
|
286
|
+
).resolves.toEqual([]);
|
|
287
|
+
|
|
288
|
+
expect(stripe.subscriptions.update).not.toHaveBeenCalled();
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
it("leaves an unpinned subscription alone - it already follows the customer default", async () => {
|
|
292
|
+
stripe.subscriptions.list.mockResolvedValue({
|
|
293
|
+
data: [
|
|
294
|
+
subscription({
|
|
295
|
+
id: METERED_SUBSCRIPTION_ID,
|
|
296
|
+
defaultPaymentMethod: null,
|
|
297
|
+
}),
|
|
298
|
+
],
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
await expect(
|
|
302
|
+
service.syncSubscriptionPaymentMethodsWithCustomerDefault(CUSTOMER_ID),
|
|
303
|
+
).resolves.toEqual([]);
|
|
304
|
+
|
|
305
|
+
expect(stripe.subscriptions.update).not.toHaveBeenCalled();
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
it("clears a legacy default_source, which also outranks the customer default", async () => {
|
|
309
|
+
stripe.subscriptions.list.mockResolvedValue({
|
|
310
|
+
data: [
|
|
311
|
+
subscription({
|
|
312
|
+
id: METERED_SUBSCRIPTION_ID,
|
|
313
|
+
defaultPaymentMethod: null,
|
|
314
|
+
defaultSource: "card_legacy_source",
|
|
315
|
+
}),
|
|
316
|
+
],
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
await expect(
|
|
320
|
+
service.syncSubscriptionPaymentMethodsWithCustomerDefault(CUSTOMER_ID),
|
|
321
|
+
).resolves.toEqual([METERED_SUBSCRIPTION_ID]);
|
|
322
|
+
|
|
323
|
+
expect(stripe.subscriptions.update).toHaveBeenCalledWith(
|
|
324
|
+
METERED_SUBSCRIPTION_ID,
|
|
325
|
+
{ default_source: "" },
|
|
326
|
+
);
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
it("clears a stale pin and a legacy source together in a single update", async () => {
|
|
330
|
+
stripe.subscriptions.list.mockResolvedValue({
|
|
331
|
+
data: [
|
|
332
|
+
subscription({
|
|
333
|
+
id: METERED_SUBSCRIPTION_ID,
|
|
334
|
+
defaultPaymentMethod: OLD_CARD_ID,
|
|
335
|
+
defaultSource: "card_legacy_source",
|
|
336
|
+
}),
|
|
337
|
+
],
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
await service.syncSubscriptionPaymentMethodsWithCustomerDefault(
|
|
341
|
+
CUSTOMER_ID,
|
|
342
|
+
);
|
|
343
|
+
|
|
344
|
+
expect(stripe.subscriptions.update).toHaveBeenCalledTimes(1);
|
|
345
|
+
expect(stripe.subscriptions.update).toHaveBeenCalledWith(
|
|
346
|
+
METERED_SUBSCRIPTION_ID,
|
|
347
|
+
{ default_payment_method: "", default_source: "" },
|
|
348
|
+
);
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
it("clears only the legacy source when the pin already matches the default", async () => {
|
|
352
|
+
stripe.subscriptions.list.mockResolvedValue({
|
|
353
|
+
data: [
|
|
354
|
+
subscription({
|
|
355
|
+
id: METERED_SUBSCRIPTION_ID,
|
|
356
|
+
defaultPaymentMethod: NEW_CARD_ID,
|
|
357
|
+
defaultSource: "card_legacy_source",
|
|
358
|
+
}),
|
|
359
|
+
],
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
await service.syncSubscriptionPaymentMethodsWithCustomerDefault(
|
|
363
|
+
CUSTOMER_ID,
|
|
364
|
+
);
|
|
365
|
+
|
|
366
|
+
expect(stripe.subscriptions.update).toHaveBeenCalledWith(
|
|
367
|
+
METERED_SUBSCRIPTION_ID,
|
|
368
|
+
{ default_source: "" },
|
|
369
|
+
);
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
it.each([
|
|
373
|
+
"canceled",
|
|
374
|
+
"incomplete_expired",
|
|
375
|
+
] as Array<Stripe.Subscription.Status>)(
|
|
376
|
+
"skips a %s subscription, which raises no more invoices and cannot be updated",
|
|
377
|
+
async (status: Stripe.Subscription.Status) => {
|
|
378
|
+
stripe.subscriptions.list.mockResolvedValue({
|
|
379
|
+
data: [
|
|
380
|
+
subscription({
|
|
381
|
+
id: METERED_SUBSCRIPTION_ID,
|
|
382
|
+
status: status,
|
|
383
|
+
defaultPaymentMethod: OLD_CARD_ID,
|
|
384
|
+
defaultSource: "card_legacy_source",
|
|
385
|
+
}),
|
|
386
|
+
],
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
await expect(
|
|
390
|
+
service.syncSubscriptionPaymentMethodsWithCustomerDefault(
|
|
391
|
+
CUSTOMER_ID,
|
|
392
|
+
),
|
|
393
|
+
).resolves.toEqual([]);
|
|
394
|
+
|
|
395
|
+
expect(stripe.subscriptions.update).not.toHaveBeenCalled();
|
|
396
|
+
},
|
|
397
|
+
);
|
|
398
|
+
|
|
399
|
+
it.each([
|
|
400
|
+
"past_due",
|
|
401
|
+
"unpaid",
|
|
402
|
+
"active",
|
|
403
|
+
"trialing",
|
|
404
|
+
] as Array<Stripe.Subscription.Status>)(
|
|
405
|
+
"unpins a %s subscription that is still pinned to a replaced card",
|
|
406
|
+
async (status: Stripe.Subscription.Status) => {
|
|
407
|
+
stripe.subscriptions.list.mockResolvedValue({
|
|
408
|
+
data: [
|
|
409
|
+
subscription({
|
|
410
|
+
id: METERED_SUBSCRIPTION_ID,
|
|
411
|
+
status: status,
|
|
412
|
+
defaultPaymentMethod: OLD_CARD_ID,
|
|
413
|
+
}),
|
|
414
|
+
],
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
await expect(
|
|
418
|
+
service.syncSubscriptionPaymentMethodsWithCustomerDefault(
|
|
419
|
+
CUSTOMER_ID,
|
|
420
|
+
),
|
|
421
|
+
).resolves.toEqual([METERED_SUBSCRIPTION_ID]);
|
|
422
|
+
|
|
423
|
+
expect(stripe.subscriptions.update).toHaveBeenCalledWith(
|
|
424
|
+
METERED_SUBSCRIPTION_ID,
|
|
425
|
+
{ default_payment_method: "" },
|
|
426
|
+
);
|
|
427
|
+
},
|
|
428
|
+
);
|
|
429
|
+
|
|
430
|
+
/*
|
|
431
|
+
* Stripe refuses a default_payment_method update on an `incomplete`
|
|
432
|
+
* subscription: "A subscription in this state can only have metadata and
|
|
433
|
+
* default_source updated". Clearing a pin there is worth nothing (the
|
|
434
|
+
* subscription's only invoice is voided within 23 hours) and asking for it
|
|
435
|
+
* would fail the repair for the customer we are repairing.
|
|
436
|
+
*/
|
|
437
|
+
describe("an incomplete subscription, which Stripe refuses to repin", () => {
|
|
438
|
+
const INCOMPLETE_SUBSCRIPTION_ID: string = "sub_incomplete_first_invoice";
|
|
439
|
+
|
|
440
|
+
type RefuseFunction = () => void;
|
|
441
|
+
|
|
442
|
+
const refusePaymentMethodUpdateOnIncomplete: RefuseFunction =
|
|
443
|
+
(): void => {
|
|
444
|
+
stripe.subscriptions.update.mockImplementation(
|
|
445
|
+
(id: unknown, params: unknown) => {
|
|
446
|
+
const updateParams: Stripe.SubscriptionUpdateParams =
|
|
447
|
+
params as Stripe.SubscriptionUpdateParams;
|
|
448
|
+
|
|
449
|
+
if (
|
|
450
|
+
id === INCOMPLETE_SUBSCRIPTION_ID &&
|
|
451
|
+
updateParams.default_payment_method !== undefined
|
|
452
|
+
) {
|
|
453
|
+
return Promise.reject(
|
|
454
|
+
providerError({
|
|
455
|
+
statusCode: 400,
|
|
456
|
+
type: "StripeInvalidRequestError",
|
|
457
|
+
rawType: "invalid_request_error",
|
|
458
|
+
message:
|
|
459
|
+
"This subscription can only have metadata and default_source updated.",
|
|
460
|
+
}),
|
|
461
|
+
);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
return Promise.resolve({});
|
|
465
|
+
},
|
|
466
|
+
);
|
|
467
|
+
};
|
|
468
|
+
|
|
469
|
+
beforeEach(() => {
|
|
470
|
+
refusePaymentMethodUpdateOnIncomplete();
|
|
471
|
+
});
|
|
472
|
+
|
|
473
|
+
it("leaves the pin alone instead of asking for an update Stripe rejects", async () => {
|
|
474
|
+
stripe.subscriptions.list.mockResolvedValue({
|
|
475
|
+
data: [
|
|
476
|
+
subscription({
|
|
477
|
+
id: INCOMPLETE_SUBSCRIPTION_ID,
|
|
478
|
+
status: "incomplete",
|
|
479
|
+
defaultPaymentMethod: OLD_CARD_ID,
|
|
480
|
+
}),
|
|
481
|
+
],
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
await expect(
|
|
485
|
+
service.syncSubscriptionPaymentMethodsWithCustomerDefault(
|
|
486
|
+
CUSTOMER_ID,
|
|
487
|
+
),
|
|
488
|
+
).resolves.toEqual([]);
|
|
489
|
+
|
|
490
|
+
expect(stripe.subscriptions.update).not.toHaveBeenCalled();
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
it("still clears its legacy default_source, the one field Stripe does allow", async () => {
|
|
494
|
+
stripe.subscriptions.list.mockResolvedValue({
|
|
495
|
+
data: [
|
|
496
|
+
subscription({
|
|
497
|
+
id: INCOMPLETE_SUBSCRIPTION_ID,
|
|
498
|
+
status: "incomplete",
|
|
499
|
+
defaultPaymentMethod: OLD_CARD_ID,
|
|
500
|
+
defaultSource: "card_legacy_source",
|
|
501
|
+
}),
|
|
502
|
+
],
|
|
503
|
+
});
|
|
504
|
+
|
|
505
|
+
await expect(
|
|
506
|
+
service.syncSubscriptionPaymentMethodsWithCustomerDefault(
|
|
507
|
+
CUSTOMER_ID,
|
|
508
|
+
),
|
|
509
|
+
).resolves.toEqual([INCOMPLETE_SUBSCRIPTION_ID]);
|
|
510
|
+
|
|
511
|
+
expect(stripe.subscriptions.update).toHaveBeenCalledTimes(1);
|
|
512
|
+
expect(stripe.subscriptions.update).toHaveBeenCalledWith(
|
|
513
|
+
INCOMPLETE_SUBSCRIPTION_ID,
|
|
514
|
+
{ default_source: "" },
|
|
515
|
+
);
|
|
516
|
+
});
|
|
517
|
+
|
|
518
|
+
it("does not stop the repair of the live subscription next to it", async () => {
|
|
519
|
+
/*
|
|
520
|
+
* The shape that would have broken the fix for the affected customer: a leftover
|
|
521
|
+
* incomplete subscription from a failed first charge sits beside the
|
|
522
|
+
* metered subscription that is actually charging the replaced card.
|
|
523
|
+
*/
|
|
524
|
+
stripe.subscriptions.list.mockResolvedValue({
|
|
525
|
+
data: [
|
|
526
|
+
subscription({
|
|
527
|
+
id: INCOMPLETE_SUBSCRIPTION_ID,
|
|
528
|
+
status: "incomplete",
|
|
529
|
+
defaultPaymentMethod: OLD_CARD_ID,
|
|
530
|
+
}),
|
|
531
|
+
subscription({
|
|
532
|
+
id: METERED_SUBSCRIPTION_ID,
|
|
533
|
+
status: "past_due",
|
|
534
|
+
defaultPaymentMethod: OLD_CARD_ID,
|
|
535
|
+
}),
|
|
536
|
+
],
|
|
537
|
+
});
|
|
538
|
+
|
|
539
|
+
await expect(
|
|
540
|
+
service.syncSubscriptionPaymentMethodsWithCustomerDefault(
|
|
541
|
+
CUSTOMER_ID,
|
|
542
|
+
),
|
|
543
|
+
).resolves.toEqual([METERED_SUBSCRIPTION_ID]);
|
|
544
|
+
|
|
545
|
+
expect(stripe.subscriptions.update).toHaveBeenCalledTimes(1);
|
|
546
|
+
expect(stripe.subscriptions.update).toHaveBeenCalledWith(
|
|
547
|
+
METERED_SUBSCRIPTION_ID,
|
|
548
|
+
{ default_payment_method: "" },
|
|
549
|
+
);
|
|
550
|
+
});
|
|
551
|
+
|
|
552
|
+
it("lets makePaymentMethodDefault succeed with one beside the live subscription", async () => {
|
|
553
|
+
stripe.paymentMethods.retrieve.mockResolvedValue(
|
|
554
|
+
card(NEW_CARD_ID, "1111"),
|
|
555
|
+
);
|
|
556
|
+
stripe.subscriptions.list.mockResolvedValue({
|
|
557
|
+
data: [
|
|
558
|
+
subscription({
|
|
559
|
+
id: INCOMPLETE_SUBSCRIPTION_ID,
|
|
560
|
+
status: "incomplete",
|
|
561
|
+
defaultPaymentMethod: OLD_CARD_ID,
|
|
562
|
+
}),
|
|
563
|
+
subscription({
|
|
564
|
+
id: METERED_SUBSCRIPTION_ID,
|
|
565
|
+
status: "past_due",
|
|
566
|
+
defaultPaymentMethod: OLD_CARD_ID,
|
|
567
|
+
}),
|
|
568
|
+
],
|
|
569
|
+
});
|
|
570
|
+
|
|
571
|
+
await expect(
|
|
572
|
+
service.makePaymentMethodDefault(CUSTOMER_ID, NEW_CARD_ID),
|
|
573
|
+
).resolves.toBeUndefined();
|
|
574
|
+
|
|
575
|
+
expect(stripe.customers.update).toHaveBeenCalledWith(CUSTOMER_ID, {
|
|
576
|
+
invoice_settings: { default_payment_method: NEW_CARD_ID },
|
|
577
|
+
});
|
|
578
|
+
expect(stripe.subscriptions.update).toHaveBeenCalledTimes(1);
|
|
579
|
+
expect(stripe.subscriptions.update).toHaveBeenCalledWith(
|
|
580
|
+
METERED_SUBSCRIPTION_ID,
|
|
581
|
+
{ default_payment_method: "" },
|
|
582
|
+
);
|
|
583
|
+
});
|
|
584
|
+
});
|
|
585
|
+
|
|
586
|
+
it("changes nothing while the customer has no default - an unpinned subscription would have no card at all", async () => {
|
|
587
|
+
stripe.customers.retrieve.mockResolvedValue(customerWithDefault(null));
|
|
588
|
+
|
|
589
|
+
await expect(
|
|
590
|
+
service.syncSubscriptionPaymentMethodsWithCustomerDefault(CUSTOMER_ID),
|
|
591
|
+
).resolves.toEqual([]);
|
|
592
|
+
|
|
593
|
+
expect(stripe.subscriptions.list).not.toHaveBeenCalled();
|
|
594
|
+
expect(stripe.subscriptions.update).not.toHaveBeenCalled();
|
|
595
|
+
});
|
|
596
|
+
|
|
597
|
+
it("changes nothing when the customer carries no invoice settings at all", async () => {
|
|
598
|
+
stripe.customers.retrieve.mockResolvedValue({ id: CUSTOMER_ID });
|
|
599
|
+
|
|
600
|
+
await expect(
|
|
601
|
+
service.syncSubscriptionPaymentMethodsWithCustomerDefault(CUSTOMER_ID),
|
|
602
|
+
).resolves.toEqual([]);
|
|
603
|
+
|
|
604
|
+
expect(stripe.subscriptions.list).not.toHaveBeenCalled();
|
|
605
|
+
expect(stripe.subscriptions.update).not.toHaveBeenCalled();
|
|
606
|
+
});
|
|
607
|
+
|
|
608
|
+
it("returns nothing for a deleted customer", async () => {
|
|
609
|
+
stripe.customers.retrieve.mockResolvedValue({
|
|
610
|
+
id: CUSTOMER_ID,
|
|
611
|
+
deleted: true,
|
|
612
|
+
});
|
|
613
|
+
|
|
614
|
+
await expect(
|
|
615
|
+
service.syncSubscriptionPaymentMethodsWithCustomerDefault(CUSTOMER_ID),
|
|
616
|
+
).resolves.toEqual([]);
|
|
617
|
+
|
|
618
|
+
expect(stripe.subscriptions.list).not.toHaveBeenCalled();
|
|
619
|
+
expect(stripe.subscriptions.update).not.toHaveBeenCalled();
|
|
620
|
+
});
|
|
621
|
+
|
|
622
|
+
it("reads a customer default that arrives expanded as an object", async () => {
|
|
623
|
+
stripe.customers.retrieve.mockResolvedValue(
|
|
624
|
+
customerWithDefault({ id: NEW_CARD_ID }),
|
|
625
|
+
);
|
|
626
|
+
stripe.subscriptions.list.mockResolvedValue({
|
|
627
|
+
data: [
|
|
628
|
+
subscription({
|
|
629
|
+
id: FLAT_FEE_SUBSCRIPTION_ID,
|
|
630
|
+
defaultPaymentMethod: NEW_CARD_ID,
|
|
631
|
+
}),
|
|
632
|
+
subscription({
|
|
633
|
+
id: METERED_SUBSCRIPTION_ID,
|
|
634
|
+
defaultPaymentMethod: OLD_CARD_ID,
|
|
635
|
+
}),
|
|
636
|
+
],
|
|
637
|
+
});
|
|
638
|
+
|
|
639
|
+
await expect(
|
|
640
|
+
service.syncSubscriptionPaymentMethodsWithCustomerDefault(CUSTOMER_ID),
|
|
641
|
+
).resolves.toEqual([METERED_SUBSCRIPTION_ID]);
|
|
642
|
+
|
|
643
|
+
expect(stripe.subscriptions.update).toHaveBeenCalledTimes(1);
|
|
644
|
+
expect(stripe.subscriptions.update).toHaveBeenCalledWith(
|
|
645
|
+
METERED_SUBSCRIPTION_ID,
|
|
646
|
+
{ default_payment_method: "" },
|
|
647
|
+
);
|
|
648
|
+
});
|
|
649
|
+
|
|
650
|
+
it("reads a subscription pin that arrives expanded as an object", async () => {
|
|
651
|
+
stripe.subscriptions.list.mockResolvedValue({
|
|
652
|
+
data: [
|
|
653
|
+
subscription({
|
|
654
|
+
id: FLAT_FEE_SUBSCRIPTION_ID,
|
|
655
|
+
defaultPaymentMethod: { id: NEW_CARD_ID },
|
|
656
|
+
}),
|
|
657
|
+
subscription({
|
|
658
|
+
id: METERED_SUBSCRIPTION_ID,
|
|
659
|
+
defaultPaymentMethod: { id: OLD_CARD_ID },
|
|
660
|
+
}),
|
|
661
|
+
],
|
|
662
|
+
});
|
|
663
|
+
|
|
664
|
+
await expect(
|
|
665
|
+
service.syncSubscriptionPaymentMethodsWithCustomerDefault(CUSTOMER_ID),
|
|
666
|
+
).resolves.toEqual([METERED_SUBSCRIPTION_ID]);
|
|
667
|
+
|
|
668
|
+
expect(stripe.subscriptions.update).toHaveBeenCalledTimes(1);
|
|
669
|
+
});
|
|
670
|
+
|
|
671
|
+
it("walks every subscription of the customer and updates only the stale ones", async () => {
|
|
672
|
+
stripe.subscriptions.list.mockResolvedValue({
|
|
673
|
+
data: [
|
|
674
|
+
subscription({
|
|
675
|
+
id: FLAT_FEE_SUBSCRIPTION_ID,
|
|
676
|
+
status: "active",
|
|
677
|
+
defaultPaymentMethod: OLD_CARD_ID,
|
|
678
|
+
}),
|
|
679
|
+
subscription({
|
|
680
|
+
id: METERED_SUBSCRIPTION_ID,
|
|
681
|
+
status: "past_due",
|
|
682
|
+
defaultPaymentMethod: OLD_CARD_ID,
|
|
683
|
+
}),
|
|
684
|
+
subscription({
|
|
685
|
+
id: "sub_replaced_long_ago",
|
|
686
|
+
status: "canceled",
|
|
687
|
+
defaultPaymentMethod: OLD_CARD_ID,
|
|
688
|
+
}),
|
|
689
|
+
subscription({
|
|
690
|
+
id: "sub_already_following",
|
|
691
|
+
status: "active",
|
|
692
|
+
defaultPaymentMethod: null,
|
|
693
|
+
}),
|
|
694
|
+
subscription({
|
|
695
|
+
id: "sub_pinned_to_default",
|
|
696
|
+
status: "trialing",
|
|
697
|
+
defaultPaymentMethod: NEW_CARD_ID,
|
|
698
|
+
}),
|
|
699
|
+
],
|
|
700
|
+
});
|
|
701
|
+
|
|
702
|
+
await expect(
|
|
703
|
+
service.syncSubscriptionPaymentMethodsWithCustomerDefault(CUSTOMER_ID),
|
|
704
|
+
).resolves.toEqual([FLAT_FEE_SUBSCRIPTION_ID, METERED_SUBSCRIPTION_ID]);
|
|
705
|
+
|
|
706
|
+
expect(
|
|
707
|
+
stripe.subscriptions.update.mock.calls.map((call: unknown) => {
|
|
708
|
+
return (call as UpdateCall)[0];
|
|
709
|
+
}),
|
|
710
|
+
).toEqual([FLAT_FEE_SUBSCRIPTION_ID, METERED_SUBSCRIPTION_ID]);
|
|
711
|
+
});
|
|
712
|
+
|
|
713
|
+
it("refuses when billing is disabled, before any provider request", async () => {
|
|
714
|
+
getJestSpyOn(service, "isBillingEnabled").mockReturnValue(false);
|
|
715
|
+
|
|
716
|
+
await expect(
|
|
717
|
+
service.syncSubscriptionPaymentMethodsWithCustomerDefault(CUSTOMER_ID),
|
|
718
|
+
).rejects.toThrow(Errors.BillingService.BILLING_NOT_ENABLED);
|
|
719
|
+
|
|
720
|
+
expect(stripe.customers.retrieve).not.toHaveBeenCalled();
|
|
721
|
+
expect(stripe.subscriptions.list).not.toHaveBeenCalled();
|
|
722
|
+
expect(stripe.subscriptions.update).not.toHaveBeenCalled();
|
|
723
|
+
});
|
|
724
|
+
|
|
725
|
+
/*
|
|
726
|
+
* A raw StripeError is not an OneUptime Exception, so it reaches the
|
|
727
|
+
* express handler's fallback branch and is answered as an opaque
|
|
728
|
+
* 500 {"error":"Server Error"}. On the route that repairs autopay that is
|
|
729
|
+
* the worst possible answer: the customer cannot tell a rate limit worth
|
|
730
|
+
* retrying from a card the provider refused. Provider writes are named
|
|
731
|
+
* the way provider reads already are.
|
|
732
|
+
*/
|
|
733
|
+
it("reports a rejected subscription update as bad data, carrying the provider's own words", async () => {
|
|
734
|
+
const failure: Error = providerError({
|
|
735
|
+
statusCode: 400,
|
|
736
|
+
type: "StripeInvalidRequestError",
|
|
737
|
+
message: "This subscription cannot be updated",
|
|
738
|
+
});
|
|
739
|
+
stripe.subscriptions.list.mockResolvedValue({
|
|
740
|
+
data: [
|
|
741
|
+
subscription({
|
|
742
|
+
id: FLAT_FEE_SUBSCRIPTION_ID,
|
|
743
|
+
defaultPaymentMethod: OLD_CARD_ID,
|
|
744
|
+
}),
|
|
745
|
+
subscription({
|
|
746
|
+
id: METERED_SUBSCRIPTION_ID,
|
|
747
|
+
defaultPaymentMethod: OLD_CARD_ID,
|
|
748
|
+
}),
|
|
749
|
+
],
|
|
750
|
+
});
|
|
751
|
+
stripe.subscriptions.update.mockRejectedValueOnce(failure);
|
|
752
|
+
|
|
753
|
+
const thrown: unknown = await service
|
|
754
|
+
.syncSubscriptionPaymentMethodsWithCustomerDefault(CUSTOMER_ID)
|
|
755
|
+
.catch((err: unknown) => {
|
|
756
|
+
return err;
|
|
757
|
+
});
|
|
758
|
+
|
|
759
|
+
expect(thrown).toBeInstanceOf(BadDataException);
|
|
760
|
+
expect((thrown as BadDataException).message).toBe(
|
|
761
|
+
"This subscription cannot be updated",
|
|
762
|
+
);
|
|
763
|
+
expect(thrown).not.toBe(failure);
|
|
764
|
+
expect(stripe.subscriptions.update).toHaveBeenCalledTimes(1);
|
|
765
|
+
});
|
|
766
|
+
|
|
767
|
+
it("never retries the subscription write, and reports a rate limit as the provider being unreachable", async () => {
|
|
768
|
+
const failure: Error = providerError({ statusCode: 429 });
|
|
769
|
+
stripe.subscriptions.list.mockResolvedValue({
|
|
770
|
+
data: [
|
|
771
|
+
subscription({
|
|
772
|
+
id: METERED_SUBSCRIPTION_ID,
|
|
773
|
+
defaultPaymentMethod: OLD_CARD_ID,
|
|
774
|
+
}),
|
|
775
|
+
],
|
|
776
|
+
});
|
|
777
|
+
stripe.subscriptions.update.mockRejectedValue(failure);
|
|
778
|
+
|
|
779
|
+
const thrown: unknown = await service
|
|
780
|
+
.syncSubscriptionPaymentMethodsWithCustomerDefault(CUSTOMER_ID)
|
|
781
|
+
.catch((err: unknown) => {
|
|
782
|
+
return err;
|
|
783
|
+
});
|
|
784
|
+
|
|
785
|
+
// Retrying a write can apply the change twice, so it stays a single call.
|
|
786
|
+
expect(stripe.subscriptions.update).toHaveBeenCalledTimes(1);
|
|
787
|
+
expect(thrown).toBeInstanceOf(ServiceUnavailableException);
|
|
788
|
+
expect((thrown as ServiceUnavailableException).message).toMatch(
|
|
789
|
+
/payment provider/i,
|
|
790
|
+
);
|
|
791
|
+
// 500 answers "Server Error"; this one says what the customer can do.
|
|
792
|
+
expect((thrown as ServiceUnavailableException).message).toMatch(
|
|
793
|
+
/try again/i,
|
|
794
|
+
);
|
|
795
|
+
});
|
|
796
|
+
|
|
797
|
+
it("leaves an error that is not the provider talking exactly as it is", async () => {
|
|
798
|
+
// A bug of ours must not be dressed up as a payment failure.
|
|
799
|
+
const bug: Error = new TypeError(
|
|
800
|
+
"stripe.subscriptions.update is not a function",
|
|
801
|
+
);
|
|
802
|
+
stripe.subscriptions.list.mockResolvedValue({
|
|
803
|
+
data: [
|
|
804
|
+
subscription({
|
|
805
|
+
id: METERED_SUBSCRIPTION_ID,
|
|
806
|
+
defaultPaymentMethod: OLD_CARD_ID,
|
|
807
|
+
}),
|
|
808
|
+
],
|
|
809
|
+
});
|
|
810
|
+
stripe.subscriptions.update.mockRejectedValue(bug);
|
|
811
|
+
|
|
812
|
+
await expect(
|
|
813
|
+
service.syncSubscriptionPaymentMethodsWithCustomerDefault(CUSTOMER_ID),
|
|
814
|
+
).rejects.toBe(bug);
|
|
815
|
+
});
|
|
816
|
+
|
|
817
|
+
it("retries a rate-limited customer read and still clears the pin", async () => {
|
|
818
|
+
stripe.customers.retrieve
|
|
819
|
+
.mockRejectedValueOnce(providerError({ statusCode: 429 }))
|
|
820
|
+
.mockResolvedValue(customerWithDefault(NEW_CARD_ID));
|
|
821
|
+
stripe.subscriptions.list.mockResolvedValue({
|
|
822
|
+
data: [
|
|
823
|
+
subscription({
|
|
824
|
+
id: METERED_SUBSCRIPTION_ID,
|
|
825
|
+
defaultPaymentMethod: OLD_CARD_ID,
|
|
826
|
+
}),
|
|
827
|
+
],
|
|
828
|
+
});
|
|
829
|
+
|
|
830
|
+
await expect(
|
|
831
|
+
service.syncSubscriptionPaymentMethodsWithCustomerDefault(CUSTOMER_ID),
|
|
832
|
+
).resolves.toEqual([METERED_SUBSCRIPTION_ID]);
|
|
833
|
+
|
|
834
|
+
expect(stripe.customers.retrieve).toHaveBeenCalledTimes(2);
|
|
835
|
+
});
|
|
836
|
+
|
|
837
|
+
it("propagates a subscription list that cannot be read, and writes nothing", async () => {
|
|
838
|
+
const failure: Error = providerError({ statusCode: 401 });
|
|
839
|
+
stripe.subscriptions.list.mockRejectedValue(failure);
|
|
840
|
+
|
|
841
|
+
await expect(
|
|
842
|
+
service.syncSubscriptionPaymentMethodsWithCustomerDefault(CUSTOMER_ID),
|
|
843
|
+
).rejects.toBe(failure);
|
|
844
|
+
|
|
845
|
+
expect(stripe.subscriptions.update).not.toHaveBeenCalled();
|
|
846
|
+
});
|
|
847
|
+
});
|
|
848
|
+
|
|
849
|
+
describe("makePaymentMethodDefault", () => {
|
|
850
|
+
beforeEach(() => {
|
|
851
|
+
stripe.paymentMethods.retrieve.mockResolvedValue(
|
|
852
|
+
card(NEW_CARD_ID, "1111"),
|
|
853
|
+
);
|
|
854
|
+
stripe.subscriptions.list.mockResolvedValue({
|
|
855
|
+
data: [
|
|
856
|
+
subscription({
|
|
857
|
+
id: METERED_SUBSCRIPTION_ID,
|
|
858
|
+
status: "past_due",
|
|
859
|
+
defaultPaymentMethod: OLD_CARD_ID,
|
|
860
|
+
}),
|
|
861
|
+
],
|
|
862
|
+
});
|
|
863
|
+
});
|
|
864
|
+
|
|
865
|
+
it("makes the replacement card the default and moves autopay onto it", async () => {
|
|
866
|
+
// What the sync reads back once the new default has been written.
|
|
867
|
+
stripe.customers.retrieve.mockResolvedValue(
|
|
868
|
+
customerWithDefault(NEW_CARD_ID),
|
|
869
|
+
);
|
|
870
|
+
|
|
871
|
+
await expect(
|
|
872
|
+
service.makePaymentMethodDefault(CUSTOMER_ID, NEW_CARD_ID),
|
|
873
|
+
).resolves.toBeUndefined();
|
|
874
|
+
|
|
875
|
+
expect(stripe.paymentMethods.retrieve).toHaveBeenCalledWith(NEW_CARD_ID);
|
|
876
|
+
expect(stripe.customers.update).toHaveBeenCalledWith(CUSTOMER_ID, {
|
|
877
|
+
invoice_settings: { default_payment_method: NEW_CARD_ID },
|
|
878
|
+
});
|
|
879
|
+
expect(stripe.subscriptions.update).toHaveBeenCalledWith(
|
|
880
|
+
METERED_SUBSCRIPTION_ID,
|
|
881
|
+
{ default_payment_method: "" },
|
|
882
|
+
);
|
|
883
|
+
});
|
|
884
|
+
|
|
885
|
+
it("checks ownership first, sets the default next, and only then syncs the subscriptions", async () => {
|
|
886
|
+
await service.makePaymentMethodDefault(CUSTOMER_ID, NEW_CARD_ID);
|
|
887
|
+
|
|
888
|
+
const ownershipCheck: number = stripe.paymentMethods.retrieve.mock
|
|
889
|
+
.invocationCallOrder[0] as number;
|
|
890
|
+
const setDefault: number = stripe.customers.update.mock
|
|
891
|
+
.invocationCallOrder[0] as number;
|
|
892
|
+
const customerRead: number = stripe.customers.retrieve.mock
|
|
893
|
+
.invocationCallOrder[0] as number;
|
|
894
|
+
const subscriptionRead: number = stripe.subscriptions.list.mock
|
|
895
|
+
.invocationCallOrder[0] as number;
|
|
896
|
+
const subscriptionWrite: number = stripe.subscriptions.update.mock
|
|
897
|
+
.invocationCallOrder[0] as number;
|
|
898
|
+
|
|
899
|
+
/*
|
|
900
|
+
* The sync reads the customer default back, so it has to run after the
|
|
901
|
+
* default is written - otherwise it would compare the pins against the
|
|
902
|
+
* card being replaced and leave them where they are.
|
|
903
|
+
*/
|
|
904
|
+
expect(ownershipCheck).toBeLessThan(setDefault);
|
|
905
|
+
expect(setDefault).toBeLessThan(customerRead);
|
|
906
|
+
expect(customerRead).toBeLessThan(subscriptionRead);
|
|
907
|
+
expect(subscriptionRead).toBeLessThan(subscriptionWrite);
|
|
908
|
+
});
|
|
909
|
+
|
|
910
|
+
it("refuses a payment method attached to another customer and changes nothing", async () => {
|
|
911
|
+
stripe.paymentMethods.retrieve.mockResolvedValue(
|
|
912
|
+
card(NEW_CARD_ID, "1111", OTHER_CUSTOMER_ID),
|
|
913
|
+
);
|
|
914
|
+
|
|
915
|
+
await expect(
|
|
916
|
+
service.makePaymentMethodDefault(CUSTOMER_ID, NEW_CARD_ID),
|
|
917
|
+
).rejects.toThrow(
|
|
918
|
+
new BadDataException("Payment method does not belong to this project"),
|
|
919
|
+
);
|
|
920
|
+
|
|
921
|
+
expect(stripe.customers.update).not.toHaveBeenCalled();
|
|
922
|
+
expect(stripe.subscriptions.list).not.toHaveBeenCalled();
|
|
923
|
+
expect(stripe.subscriptions.update).not.toHaveBeenCalled();
|
|
924
|
+
});
|
|
925
|
+
|
|
926
|
+
it("refuses a payment method that is no longer attached to any customer", async () => {
|
|
927
|
+
stripe.paymentMethods.retrieve.mockResolvedValue(
|
|
928
|
+
card(OLD_CARD_ID, "4242", null),
|
|
929
|
+
);
|
|
930
|
+
|
|
931
|
+
await expect(
|
|
932
|
+
service.makePaymentMethodDefault(CUSTOMER_ID, OLD_CARD_ID),
|
|
933
|
+
).rejects.toThrow("Payment method does not belong to this project");
|
|
934
|
+
|
|
935
|
+
expect(stripe.customers.update).not.toHaveBeenCalled();
|
|
936
|
+
});
|
|
937
|
+
|
|
938
|
+
it("accepts an owner that arrives expanded as a customer object", async () => {
|
|
939
|
+
stripe.paymentMethods.retrieve.mockResolvedValue(
|
|
940
|
+
card(NEW_CARD_ID, "1111", { id: CUSTOMER_ID }),
|
|
941
|
+
);
|
|
942
|
+
|
|
943
|
+
await expect(
|
|
944
|
+
service.makePaymentMethodDefault(CUSTOMER_ID, NEW_CARD_ID),
|
|
945
|
+
).resolves.toBeUndefined();
|
|
946
|
+
|
|
947
|
+
expect(stripe.customers.update).toHaveBeenCalledTimes(1);
|
|
948
|
+
});
|
|
949
|
+
|
|
950
|
+
it("refuses an expanded owner object that is another customer", async () => {
|
|
951
|
+
stripe.paymentMethods.retrieve.mockResolvedValue(
|
|
952
|
+
card(NEW_CARD_ID, "1111", { id: OTHER_CUSTOMER_ID }),
|
|
953
|
+
);
|
|
954
|
+
|
|
955
|
+
await expect(
|
|
956
|
+
service.makePaymentMethodDefault(CUSTOMER_ID, NEW_CARD_ID),
|
|
957
|
+
).rejects.toThrow("Payment method does not belong to this project");
|
|
958
|
+
|
|
959
|
+
expect(stripe.customers.update).not.toHaveBeenCalled();
|
|
960
|
+
});
|
|
961
|
+
|
|
962
|
+
it("answers a payment method Stripe does not know exactly like one owned by someone else", async () => {
|
|
963
|
+
stripe.paymentMethods.retrieve.mockRejectedValue(resourceMissing());
|
|
964
|
+
|
|
965
|
+
await expect(
|
|
966
|
+
service.makePaymentMethodDefault(CUSTOMER_ID, "pm_does_not_exist"),
|
|
967
|
+
).rejects.toThrow(
|
|
968
|
+
new BadDataException("Payment method does not belong to this project"),
|
|
969
|
+
);
|
|
970
|
+
|
|
971
|
+
expect(stripe.customers.update).not.toHaveBeenCalled();
|
|
972
|
+
});
|
|
973
|
+
|
|
974
|
+
it("propagates any other failure to read the payment method", async () => {
|
|
975
|
+
const failure: Error = providerError({
|
|
976
|
+
statusCode: 401,
|
|
977
|
+
type: "StripeAuthenticationError",
|
|
978
|
+
});
|
|
979
|
+
stripe.paymentMethods.retrieve.mockRejectedValue(failure);
|
|
980
|
+
|
|
981
|
+
await expect(
|
|
982
|
+
service.makePaymentMethodDefault(CUSTOMER_ID, NEW_CARD_ID),
|
|
983
|
+
).rejects.toBe(failure);
|
|
984
|
+
|
|
985
|
+
expect(stripe.customers.update).not.toHaveBeenCalled();
|
|
986
|
+
});
|
|
987
|
+
|
|
988
|
+
it("refuses an empty payment method id without asking the provider", async () => {
|
|
989
|
+
await expect(
|
|
990
|
+
service.makePaymentMethodDefault(CUSTOMER_ID, ""),
|
|
991
|
+
).rejects.toThrow(BadDataException);
|
|
992
|
+
|
|
993
|
+
expect(stripe.paymentMethods.retrieve).not.toHaveBeenCalled();
|
|
994
|
+
expect(stripe.customers.update).not.toHaveBeenCalled();
|
|
995
|
+
});
|
|
996
|
+
|
|
997
|
+
it("does not sync the subscriptions when the default could not be set", async () => {
|
|
998
|
+
const failure: Error = providerError({ statusCode: 500 });
|
|
999
|
+
stripe.customers.update.mockRejectedValue(failure);
|
|
1000
|
+
|
|
1001
|
+
const thrown: unknown = await service
|
|
1002
|
+
.makePaymentMethodDefault(CUSTOMER_ID, NEW_CARD_ID)
|
|
1003
|
+
.catch((err: unknown) => {
|
|
1004
|
+
return err;
|
|
1005
|
+
});
|
|
1006
|
+
|
|
1007
|
+
/*
|
|
1008
|
+
* The route hands whatever is thrown here to next(). A raw StripeError
|
|
1009
|
+
* is not an Exception, so it would be answered as
|
|
1010
|
+
* 500 {"error":"Server Error"} and the page would tell the customer
|
|
1011
|
+
* "Reason: Server Error" on the one flow that repairs autopay.
|
|
1012
|
+
*/
|
|
1013
|
+
expect(thrown).toBeInstanceOf(ServiceUnavailableException);
|
|
1014
|
+
expect((thrown as ServiceUnavailableException).message).toMatch(
|
|
1015
|
+
/payment provider/i,
|
|
1016
|
+
);
|
|
1017
|
+
expect(stripe.customers.update).toHaveBeenCalledTimes(1);
|
|
1018
|
+
expect(stripe.subscriptions.list).not.toHaveBeenCalled();
|
|
1019
|
+
expect(stripe.subscriptions.update).not.toHaveBeenCalled();
|
|
1020
|
+
});
|
|
1021
|
+
|
|
1022
|
+
it("reports a rate-limited default write as the provider being unreachable, not as Server Error", async () => {
|
|
1023
|
+
stripe.customers.update.mockRejectedValue(
|
|
1024
|
+
providerError({ statusCode: 429, message: "Too many requests" }),
|
|
1025
|
+
);
|
|
1026
|
+
|
|
1027
|
+
const thrown: unknown = await service
|
|
1028
|
+
.makePaymentMethodDefault(CUSTOMER_ID, NEW_CARD_ID)
|
|
1029
|
+
.catch((err: unknown) => {
|
|
1030
|
+
return err;
|
|
1031
|
+
});
|
|
1032
|
+
|
|
1033
|
+
expect(thrown).toBeInstanceOf(ServiceUnavailableException);
|
|
1034
|
+
expect((thrown as ServiceUnavailableException).message).toMatch(
|
|
1035
|
+
/try again/i,
|
|
1036
|
+
);
|
|
1037
|
+
expect(stripe.customers.update).toHaveBeenCalledTimes(1);
|
|
1038
|
+
});
|
|
1039
|
+
|
|
1040
|
+
it("reports a failed subscription sync instead of telling the customer autopay moved", async () => {
|
|
1041
|
+
const failure: Error = providerError({
|
|
1042
|
+
statusCode: 400,
|
|
1043
|
+
type: "StripeInvalidRequestError",
|
|
1044
|
+
message: "This subscription cannot be updated right now.",
|
|
1045
|
+
});
|
|
1046
|
+
stripe.subscriptions.update.mockRejectedValue(failure);
|
|
1047
|
+
|
|
1048
|
+
const thrown: unknown = await service
|
|
1049
|
+
.makePaymentMethodDefault(CUSTOMER_ID, NEW_CARD_ID)
|
|
1050
|
+
.catch((err: unknown) => {
|
|
1051
|
+
return err;
|
|
1052
|
+
});
|
|
1053
|
+
|
|
1054
|
+
expect(thrown).toBeInstanceOf(BadDataException);
|
|
1055
|
+
expect((thrown as BadDataException).message).toBe(
|
|
1056
|
+
"This subscription cannot be updated right now.",
|
|
1057
|
+
);
|
|
1058
|
+
expect(stripe.customers.update).toHaveBeenCalledTimes(1);
|
|
1059
|
+
});
|
|
1060
|
+
|
|
1061
|
+
it("still clears stale pins when the card is already the customer default", async () => {
|
|
1062
|
+
/*
|
|
1063
|
+
* The existing production state: the new card is already the customer
|
|
1064
|
+
* default, but the subscription is still pinned to the old one. Choosing
|
|
1065
|
+
* the same default again is how that pin gets cleared without a data
|
|
1066
|
+
* migration.
|
|
1067
|
+
*/
|
|
1068
|
+
stripe.customers.retrieve.mockResolvedValue(
|
|
1069
|
+
customerWithDefault(NEW_CARD_ID),
|
|
1070
|
+
);
|
|
1071
|
+
|
|
1072
|
+
await service.makePaymentMethodDefault(CUSTOMER_ID, NEW_CARD_ID);
|
|
1073
|
+
|
|
1074
|
+
expect(stripe.customers.update).toHaveBeenCalledTimes(1);
|
|
1075
|
+
expect(stripe.subscriptions.update).toHaveBeenCalledWith(
|
|
1076
|
+
METERED_SUBSCRIPTION_ID,
|
|
1077
|
+
{ default_payment_method: "" },
|
|
1078
|
+
);
|
|
1079
|
+
});
|
|
1080
|
+
|
|
1081
|
+
it("refuses when billing is disabled, before any provider request", async () => {
|
|
1082
|
+
getJestSpyOn(service, "isBillingEnabled").mockReturnValue(false);
|
|
1083
|
+
|
|
1084
|
+
await expect(
|
|
1085
|
+
service.makePaymentMethodDefault(CUSTOMER_ID, NEW_CARD_ID),
|
|
1086
|
+
).rejects.toThrow(Errors.BillingService.BILLING_NOT_ENABLED);
|
|
1087
|
+
|
|
1088
|
+
expect(stripe.paymentMethods.retrieve).not.toHaveBeenCalled();
|
|
1089
|
+
expect(stripe.customers.update).not.toHaveBeenCalled();
|
|
1090
|
+
expect(stripe.subscriptions.list).not.toHaveBeenCalled();
|
|
1091
|
+
});
|
|
1092
|
+
});
|
|
1093
|
+
|
|
1094
|
+
describe("changePlan - replacement subscriptions are not pinned to a card", () => {
|
|
1095
|
+
const PROJECT_ID: ObjectID = ObjectID.generate();
|
|
1096
|
+
const plan: SubscriptionPlan = new SubscriptionPlan(
|
|
1097
|
+
"price_monthly_scale",
|
|
1098
|
+
"price_yearly_scale",
|
|
1099
|
+
"Scale",
|
|
1100
|
+
99,
|
|
1101
|
+
84,
|
|
1102
|
+
3,
|
|
1103
|
+
0,
|
|
1104
|
+
);
|
|
1105
|
+
|
|
1106
|
+
type ChangePlanFunction = () => ReturnType<BillingService["changePlan"]>;
|
|
1107
|
+
|
|
1108
|
+
const changePlan: ChangePlanFunction = (): ReturnType<
|
|
1109
|
+
BillingService["changePlan"]
|
|
1110
|
+
> => {
|
|
1111
|
+
return service.changePlan({
|
|
1112
|
+
projectId: PROJECT_ID,
|
|
1113
|
+
subscriptionId: FLAT_FEE_SUBSCRIPTION_ID,
|
|
1114
|
+
meteredSubscriptionId: METERED_SUBSCRIPTION_ID,
|
|
1115
|
+
serverMeteredPlans: [],
|
|
1116
|
+
newPlan: plan,
|
|
1117
|
+
quantity: 1,
|
|
1118
|
+
isYearly: false,
|
|
1119
|
+
});
|
|
1120
|
+
};
|
|
1121
|
+
|
|
1122
|
+
type GivenSubscriptionsFunction = (statuses: {
|
|
1123
|
+
flatFee: Stripe.Subscription.Status;
|
|
1124
|
+
metered: Stripe.Subscription.Status;
|
|
1125
|
+
}) => void;
|
|
1126
|
+
|
|
1127
|
+
const givenSubscriptions: GivenSubscriptionsFunction = (statuses: {
|
|
1128
|
+
flatFee: Stripe.Subscription.Status;
|
|
1129
|
+
metered: Stripe.Subscription.Status;
|
|
1130
|
+
}): void => {
|
|
1131
|
+
stripe.subscriptions.retrieve.mockImplementation((id: unknown) => {
|
|
1132
|
+
return Promise.resolve(
|
|
1133
|
+
id === FLAT_FEE_SUBSCRIPTION_ID
|
|
1134
|
+
? subscription({
|
|
1135
|
+
id: FLAT_FEE_SUBSCRIPTION_ID,
|
|
1136
|
+
status: statuses.flatFee,
|
|
1137
|
+
itemId: "si_flat_fee",
|
|
1138
|
+
})
|
|
1139
|
+
: subscription({
|
|
1140
|
+
id: METERED_SUBSCRIPTION_ID,
|
|
1141
|
+
status: statuses.metered,
|
|
1142
|
+
itemId: "si_metered",
|
|
1143
|
+
}),
|
|
1144
|
+
);
|
|
1145
|
+
});
|
|
1146
|
+
};
|
|
1147
|
+
|
|
1148
|
+
let paymentMethods: Array<PaymentMethod>;
|
|
1149
|
+
|
|
1150
|
+
beforeEach(() => {
|
|
1151
|
+
/*
|
|
1152
|
+
* The day of the reactivation: the old card was the customer
|
|
1153
|
+
* default, and so first in this list. That first entry is what used to
|
|
1154
|
+
* be pinned onto the replacement subscriptions.
|
|
1155
|
+
*/
|
|
1156
|
+
paymentMethods = [
|
|
1157
|
+
{
|
|
1158
|
+
id: OLD_CARD_ID,
|
|
1159
|
+
type: "visa",
|
|
1160
|
+
last4Digits: "4242",
|
|
1161
|
+
isDefault: true,
|
|
1162
|
+
},
|
|
1163
|
+
];
|
|
1164
|
+
getJestSpyOn(service, "getPaymentMethods").mockImplementation(() => {
|
|
1165
|
+
return Promise.resolve(paymentMethods);
|
|
1166
|
+
});
|
|
1167
|
+
|
|
1168
|
+
let created: number = 0;
|
|
1169
|
+
stripe.subscriptions.create.mockImplementation(() => {
|
|
1170
|
+
created++;
|
|
1171
|
+
return Promise.resolve({ id: `sub_replacement_${created}` });
|
|
1172
|
+
});
|
|
1173
|
+
});
|
|
1174
|
+
|
|
1175
|
+
type CreateParams = Stripe.SubscriptionCreateParams;
|
|
1176
|
+
|
|
1177
|
+
const createdParams: () => Array<CreateParams> =
|
|
1178
|
+
(): Array<CreateParams> => {
|
|
1179
|
+
return stripe.subscriptions.create.mock.calls.map((call: unknown) => {
|
|
1180
|
+
return (call as [CreateParams])[0];
|
|
1181
|
+
});
|
|
1182
|
+
};
|
|
1183
|
+
|
|
1184
|
+
it("recreates both halves of a reactivated project without default_payment_method", async () => {
|
|
1185
|
+
givenSubscriptions({ flatFee: "canceled", metered: "canceled" });
|
|
1186
|
+
|
|
1187
|
+
const result: Awaited<ReturnType<BillingService["changePlan"]>> =
|
|
1188
|
+
await changePlan();
|
|
1189
|
+
|
|
1190
|
+
expect(result.subscriptionId).toBe("sub_replacement_1");
|
|
1191
|
+
expect(result.meteredSubscriptionId).toBe("sub_replacement_2");
|
|
1192
|
+
|
|
1193
|
+
const params: Array<CreateParams> = createdParams();
|
|
1194
|
+
expect(params).toHaveLength(2);
|
|
1195
|
+
|
|
1196
|
+
for (const createParams of params) {
|
|
1197
|
+
expect(createParams.customer).toBe(CUSTOMER_ID);
|
|
1198
|
+
expect(createParams).not.toHaveProperty("default_payment_method");
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
// The flat fee carries the plan's price; the metered one does not.
|
|
1202
|
+
expect(params[0]?.items).toEqual([
|
|
1203
|
+
{ price: "price_monthly_scale", quantity: 1 },
|
|
1204
|
+
]);
|
|
1205
|
+
});
|
|
1206
|
+
|
|
1207
|
+
it("does not pin the flat-fee replacement when only the flat-fee subscription is dead", async () => {
|
|
1208
|
+
givenSubscriptions({ flatFee: "unpaid", metered: "active" });
|
|
1209
|
+
|
|
1210
|
+
await changePlan();
|
|
1211
|
+
|
|
1212
|
+
const params: Array<CreateParams> = createdParams();
|
|
1213
|
+
expect(params).toHaveLength(1);
|
|
1214
|
+
expect(params[0]).not.toHaveProperty("default_payment_method");
|
|
1215
|
+
expect(params[0]?.items).toEqual([
|
|
1216
|
+
{ price: "price_monthly_scale", quantity: 1 },
|
|
1217
|
+
]);
|
|
1218
|
+
});
|
|
1219
|
+
|
|
1220
|
+
it("does not pin the metered replacement when only the metered subscription is dead", async () => {
|
|
1221
|
+
givenSubscriptions({ flatFee: "active", metered: "incomplete_expired" });
|
|
1222
|
+
|
|
1223
|
+
await changePlan();
|
|
1224
|
+
|
|
1225
|
+
const params: Array<CreateParams> = createdParams();
|
|
1226
|
+
expect(params).toHaveLength(1);
|
|
1227
|
+
expect(params[0]).not.toHaveProperty("default_payment_method");
|
|
1228
|
+
expect(params[0]?.metadata).toEqual({
|
|
1229
|
+
projectId: PROJECT_ID.toString(),
|
|
1230
|
+
replacedSubscriptionId: METERED_SUBSCRIPTION_ID,
|
|
1231
|
+
});
|
|
1232
|
+
});
|
|
1233
|
+
|
|
1234
|
+
it("does not pin even when the customer has several cards", async () => {
|
|
1235
|
+
paymentMethods = [
|
|
1236
|
+
{ id: NEW_CARD_ID, type: "visa", last4Digits: "1111", isDefault: true },
|
|
1237
|
+
{
|
|
1238
|
+
id: OLD_CARD_ID,
|
|
1239
|
+
type: "visa",
|
|
1240
|
+
last4Digits: "4242",
|
|
1241
|
+
isDefault: false,
|
|
1242
|
+
},
|
|
1243
|
+
];
|
|
1244
|
+
givenSubscriptions({ flatFee: "canceled", metered: "canceled" });
|
|
1245
|
+
|
|
1246
|
+
await changePlan();
|
|
1247
|
+
|
|
1248
|
+
for (const createParams of createdParams()) {
|
|
1249
|
+
expect(createParams).not.toHaveProperty("default_payment_method");
|
|
1250
|
+
}
|
|
1251
|
+
});
|
|
1252
|
+
|
|
1253
|
+
it("still refuses to create subscriptions for a customer with no payment method", async () => {
|
|
1254
|
+
paymentMethods = [];
|
|
1255
|
+
givenSubscriptions({ flatFee: "canceled", metered: "canceled" });
|
|
1256
|
+
|
|
1257
|
+
await expect(changePlan()).rejects.toThrow(
|
|
1258
|
+
Errors.BillingService.NO_PAYMENTS_METHODS,
|
|
1259
|
+
);
|
|
1260
|
+
|
|
1261
|
+
expect(stripe.subscriptions.create).not.toHaveBeenCalled();
|
|
1262
|
+
expect(stripe.subscriptions.del).not.toHaveBeenCalled();
|
|
1263
|
+
});
|
|
1264
|
+
|
|
1265
|
+
it("leaves an explicitly requested pin working for direct subscribeToPlan callers", async () => {
|
|
1266
|
+
await service.subscribeToPlan({
|
|
1267
|
+
projectId: PROJECT_ID,
|
|
1268
|
+
customerId: CUSTOMER_ID,
|
|
1269
|
+
serverMeteredPlans: [],
|
|
1270
|
+
plan: plan,
|
|
1271
|
+
quantity: 1,
|
|
1272
|
+
isYearly: false,
|
|
1273
|
+
trial: false,
|
|
1274
|
+
defaultPaymentMethodId: NEW_CARD_ID,
|
|
1275
|
+
});
|
|
1276
|
+
|
|
1277
|
+
for (const createParams of createdParams()) {
|
|
1278
|
+
expect(createParams.default_payment_method).toBe(NEW_CARD_ID);
|
|
1279
|
+
}
|
|
1280
|
+
});
|
|
1281
|
+
});
|
|
1282
|
+
|
|
1283
|
+
describe("getPaymentMethods - promoting a first default syncs the subscriptions", () => {
|
|
1284
|
+
beforeEach(() => {
|
|
1285
|
+
stripe.paymentMethods.list.mockImplementation((params: unknown) => {
|
|
1286
|
+
return Promise.resolve({
|
|
1287
|
+
data:
|
|
1288
|
+
(params as Stripe.PaymentMethodListParams).type === "card"
|
|
1289
|
+
? [card(NEW_CARD_ID, "1111")]
|
|
1290
|
+
: [],
|
|
1291
|
+
});
|
|
1292
|
+
});
|
|
1293
|
+
stripe.subscriptions.list.mockResolvedValue({
|
|
1294
|
+
data: [
|
|
1295
|
+
subscription({
|
|
1296
|
+
id: METERED_SUBSCRIPTION_ID,
|
|
1297
|
+
status: "past_due",
|
|
1298
|
+
defaultPaymentMethod: OLD_CARD_ID,
|
|
1299
|
+
}),
|
|
1300
|
+
],
|
|
1301
|
+
});
|
|
1302
|
+
});
|
|
1303
|
+
|
|
1304
|
+
it("points subscriptions pinned to another card at the default it just promoted", async () => {
|
|
1305
|
+
// First read: no default. The sync then reads the default just written.
|
|
1306
|
+
stripe.customers.retrieve
|
|
1307
|
+
.mockResolvedValueOnce(customerWithDefault(null))
|
|
1308
|
+
.mockResolvedValue(customerWithDefault(NEW_CARD_ID));
|
|
1309
|
+
|
|
1310
|
+
await expect(service.getPaymentMethods(CUSTOMER_ID)).resolves.toEqual([
|
|
1311
|
+
{ id: NEW_CARD_ID, type: "visa", last4Digits: "1111", isDefault: true },
|
|
1312
|
+
]);
|
|
1313
|
+
|
|
1314
|
+
expect(stripe.customers.update).toHaveBeenCalledWith(CUSTOMER_ID, {
|
|
1315
|
+
invoice_settings: { default_payment_method: NEW_CARD_ID },
|
|
1316
|
+
});
|
|
1317
|
+
expect(stripe.subscriptions.update).toHaveBeenCalledWith(
|
|
1318
|
+
METERED_SUBSCRIPTION_ID,
|
|
1319
|
+
{ default_payment_method: "" },
|
|
1320
|
+
);
|
|
1321
|
+
expect(
|
|
1322
|
+
stripe.customers.update.mock.invocationCallOrder[0] as number,
|
|
1323
|
+
).toBeLessThan(
|
|
1324
|
+
stripe.subscriptions.list.mock.invocationCallOrder[0] as number,
|
|
1325
|
+
);
|
|
1326
|
+
});
|
|
1327
|
+
|
|
1328
|
+
it.each([
|
|
1329
|
+
[
|
|
1330
|
+
"the subscription list cannot be read",
|
|
1331
|
+
(fake: FakeStripe): void => {
|
|
1332
|
+
fake.subscriptions.list.mockRejectedValue(
|
|
1333
|
+
providerError({ statusCode: 400 }),
|
|
1334
|
+
);
|
|
1335
|
+
},
|
|
1336
|
+
],
|
|
1337
|
+
[
|
|
1338
|
+
"a subscription cannot be updated",
|
|
1339
|
+
(fake: FakeStripe): void => {
|
|
1340
|
+
fake.subscriptions.update.mockRejectedValue(
|
|
1341
|
+
providerError({ statusCode: 400 }),
|
|
1342
|
+
);
|
|
1343
|
+
},
|
|
1344
|
+
],
|
|
1345
|
+
[
|
|
1346
|
+
"the customer cannot be read back",
|
|
1347
|
+
(fake: FakeStripe): void => {
|
|
1348
|
+
fake.customers.retrieve
|
|
1349
|
+
.mockReset()
|
|
1350
|
+
.mockResolvedValueOnce(customerWithDefault(null))
|
|
1351
|
+
.mockRejectedValue(providerError({ statusCode: 401 }));
|
|
1352
|
+
},
|
|
1353
|
+
],
|
|
1354
|
+
])(
|
|
1355
|
+
"still answers the read when %s",
|
|
1356
|
+
async (_case: string, breakSync: (fake: FakeStripe) => void) => {
|
|
1357
|
+
stripe.customers.retrieve
|
|
1358
|
+
.mockResolvedValueOnce(customerWithDefault(null))
|
|
1359
|
+
.mockResolvedValue(customerWithDefault(NEW_CARD_ID));
|
|
1360
|
+
breakSync(stripe);
|
|
1361
|
+
|
|
1362
|
+
await expect(service.getPaymentMethods(CUSTOMER_ID)).resolves.toEqual([
|
|
1363
|
+
{
|
|
1364
|
+
id: NEW_CARD_ID,
|
|
1365
|
+
type: "visa",
|
|
1366
|
+
last4Digits: "1111",
|
|
1367
|
+
isDefault: true,
|
|
1368
|
+
},
|
|
1369
|
+
]);
|
|
1370
|
+
|
|
1371
|
+
expect(stripe.customers.update).toHaveBeenCalledTimes(1);
|
|
1372
|
+
expect(loggerError).toHaveBeenCalled();
|
|
1373
|
+
},
|
|
1374
|
+
);
|
|
1375
|
+
|
|
1376
|
+
it("keeps the common path free of subscription reads when a default already exists", async () => {
|
|
1377
|
+
stripe.customers.retrieve.mockResolvedValue(
|
|
1378
|
+
customerWithDefault(NEW_CARD_ID),
|
|
1379
|
+
);
|
|
1380
|
+
|
|
1381
|
+
await service.getPaymentMethods(CUSTOMER_ID);
|
|
1382
|
+
|
|
1383
|
+
/*
|
|
1384
|
+
* Every billing page render reads payment methods. A subscription read
|
|
1385
|
+
* per render is the kind of provider traffic that held the account at
|
|
1386
|
+
* its rate limit before.
|
|
1387
|
+
*/
|
|
1388
|
+
expect(stripe.customers.retrieve).toHaveBeenCalledTimes(1);
|
|
1389
|
+
expect(stripe.customers.update).not.toHaveBeenCalled();
|
|
1390
|
+
expect(stripe.subscriptions.list).not.toHaveBeenCalled();
|
|
1391
|
+
expect(stripe.subscriptions.update).not.toHaveBeenCalled();
|
|
1392
|
+
});
|
|
1393
|
+
|
|
1394
|
+
it("does not sync when the stored default is a card that is not in the list", async () => {
|
|
1395
|
+
stripe.customers.retrieve.mockResolvedValue(
|
|
1396
|
+
customerWithDefault("pm_detached"),
|
|
1397
|
+
);
|
|
1398
|
+
|
|
1399
|
+
await service.getPaymentMethods(CUSTOMER_ID);
|
|
1400
|
+
|
|
1401
|
+
expect(stripe.customers.update).not.toHaveBeenCalled();
|
|
1402
|
+
expect(stripe.subscriptions.list).not.toHaveBeenCalled();
|
|
1403
|
+
});
|
|
1404
|
+
|
|
1405
|
+
it("promotes nothing and syncs nothing when the customer has no payment method", async () => {
|
|
1406
|
+
stripe.paymentMethods.list.mockResolvedValue({ data: [] });
|
|
1407
|
+
stripe.customers.retrieve.mockResolvedValue(customerWithDefault(null));
|
|
1408
|
+
|
|
1409
|
+
await expect(service.getPaymentMethods(CUSTOMER_ID)).resolves.toEqual([]);
|
|
1410
|
+
|
|
1411
|
+
expect(stripe.customers.update).not.toHaveBeenCalled();
|
|
1412
|
+
expect(stripe.subscriptions.list).not.toHaveBeenCalled();
|
|
1413
|
+
});
|
|
1414
|
+
|
|
1415
|
+
it("still fails the read when the default itself cannot be written, and syncs nothing", async () => {
|
|
1416
|
+
const failure: Error = providerError({ statusCode: 500 });
|
|
1417
|
+
stripe.customers.retrieve.mockResolvedValue(customerWithDefault(null));
|
|
1418
|
+
stripe.customers.update.mockRejectedValue(failure);
|
|
1419
|
+
|
|
1420
|
+
// Named, rather than the raw StripeError's opaque 500 "Server Error".
|
|
1421
|
+
await expect(service.getPaymentMethods(CUSTOMER_ID)).rejects.toThrow(
|
|
1422
|
+
ServiceUnavailableException,
|
|
1423
|
+
);
|
|
1424
|
+
|
|
1425
|
+
expect(stripe.subscriptions.list).not.toHaveBeenCalled();
|
|
1426
|
+
});
|
|
1427
|
+
});
|
|
1428
|
+
|
|
1429
|
+
describe("deletePaymentMethod - keeps a default and re-syncs the subscriptions", () => {
|
|
1430
|
+
let paymentMethods: Array<PaymentMethod>;
|
|
1431
|
+
|
|
1432
|
+
beforeEach(() => {
|
|
1433
|
+
paymentMethods = [
|
|
1434
|
+
{ id: OLD_CARD_ID, type: "visa", last4Digits: "4242", isDefault: true },
|
|
1435
|
+
{
|
|
1436
|
+
id: NEW_CARD_ID,
|
|
1437
|
+
type: "visa",
|
|
1438
|
+
last4Digits: "1111",
|
|
1439
|
+
isDefault: false,
|
|
1440
|
+
},
|
|
1441
|
+
];
|
|
1442
|
+
getJestSpyOn(service, "getPaymentMethods").mockImplementation(() => {
|
|
1443
|
+
return Promise.resolve(paymentMethods);
|
|
1444
|
+
});
|
|
1445
|
+
stripe.paymentMethods.retrieve.mockImplementation((id: unknown) => {
|
|
1446
|
+
return Promise.resolve(card(id as string, "0000"));
|
|
1447
|
+
});
|
|
1448
|
+
stripe.subscriptions.list.mockResolvedValue({
|
|
1449
|
+
data: [
|
|
1450
|
+
subscription({
|
|
1451
|
+
id: METERED_SUBSCRIPTION_ID,
|
|
1452
|
+
status: "past_due",
|
|
1453
|
+
defaultPaymentMethod: OLD_CARD_ID,
|
|
1454
|
+
}),
|
|
1455
|
+
],
|
|
1456
|
+
});
|
|
1457
|
+
});
|
|
1458
|
+
|
|
1459
|
+
it("promotes the remaining card when the affected customer deletes the old default card, and unpins autopay from it", async () => {
|
|
1460
|
+
// Stripe clears the customer default when the default card is detached.
|
|
1461
|
+
stripe.customers.retrieve.mockResolvedValue(
|
|
1462
|
+
customerWithDefault(NEW_CARD_ID),
|
|
1463
|
+
);
|
|
1464
|
+
|
|
1465
|
+
await expect(
|
|
1466
|
+
service.deletePaymentMethod(CUSTOMER_ID, OLD_CARD_ID),
|
|
1467
|
+
).resolves.toBeUndefined();
|
|
1468
|
+
|
|
1469
|
+
expect(stripe.paymentMethods.detach).toHaveBeenCalledWith(OLD_CARD_ID);
|
|
1470
|
+
expect(stripe.customers.update).toHaveBeenCalledWith(CUSTOMER_ID, {
|
|
1471
|
+
invoice_settings: { default_payment_method: NEW_CARD_ID },
|
|
1472
|
+
});
|
|
1473
|
+
expect(stripe.subscriptions.update).toHaveBeenCalledWith(
|
|
1474
|
+
METERED_SUBSCRIPTION_ID,
|
|
1475
|
+
{ default_payment_method: "" },
|
|
1476
|
+
);
|
|
1477
|
+
|
|
1478
|
+
const detach: number = stripe.paymentMethods.detach.mock
|
|
1479
|
+
.invocationCallOrder[0] as number;
|
|
1480
|
+
const promote: number = stripe.customers.update.mock
|
|
1481
|
+
.invocationCallOrder[0] as number;
|
|
1482
|
+
const sync: number = stripe.subscriptions.update.mock
|
|
1483
|
+
.invocationCallOrder[0] as number;
|
|
1484
|
+
expect(detach).toBeLessThan(promote);
|
|
1485
|
+
expect(promote).toBeLessThan(sync);
|
|
1486
|
+
});
|
|
1487
|
+
|
|
1488
|
+
it("keeps the existing default when a non-default card is deleted, and still syncs", async () => {
|
|
1489
|
+
stripe.customers.retrieve.mockResolvedValue(
|
|
1490
|
+
customerWithDefault(OLD_CARD_ID),
|
|
1491
|
+
);
|
|
1492
|
+
stripe.subscriptions.list.mockResolvedValue({
|
|
1493
|
+
data: [
|
|
1494
|
+
subscription({
|
|
1495
|
+
id: METERED_SUBSCRIPTION_ID,
|
|
1496
|
+
defaultPaymentMethod: NEW_CARD_ID,
|
|
1497
|
+
}),
|
|
1498
|
+
],
|
|
1499
|
+
});
|
|
1500
|
+
|
|
1501
|
+
await service.deletePaymentMethod(CUSTOMER_ID, NEW_CARD_ID);
|
|
1502
|
+
|
|
1503
|
+
expect(stripe.paymentMethods.detach).toHaveBeenCalledWith(NEW_CARD_ID);
|
|
1504
|
+
expect(stripe.customers.update).not.toHaveBeenCalled();
|
|
1505
|
+
// The subscription was pinned to the card just deleted.
|
|
1506
|
+
expect(stripe.subscriptions.update).toHaveBeenCalledWith(
|
|
1507
|
+
METERED_SUBSCRIPTION_ID,
|
|
1508
|
+
{ default_payment_method: "" },
|
|
1509
|
+
);
|
|
1510
|
+
});
|
|
1511
|
+
|
|
1512
|
+
it("promotes the first remaining card when no listed card is the default", async () => {
|
|
1513
|
+
paymentMethods = [
|
|
1514
|
+
{
|
|
1515
|
+
id: OLD_CARD_ID,
|
|
1516
|
+
type: "visa",
|
|
1517
|
+
last4Digits: "4242",
|
|
1518
|
+
isDefault: false,
|
|
1519
|
+
},
|
|
1520
|
+
{
|
|
1521
|
+
id: NEW_CARD_ID,
|
|
1522
|
+
type: "visa",
|
|
1523
|
+
last4Digits: "1111",
|
|
1524
|
+
isDefault: false,
|
|
1525
|
+
},
|
|
1526
|
+
{
|
|
1527
|
+
id: "pm_third",
|
|
1528
|
+
type: "visa",
|
|
1529
|
+
last4Digits: "9999",
|
|
1530
|
+
isDefault: false,
|
|
1531
|
+
},
|
|
1532
|
+
];
|
|
1533
|
+
|
|
1534
|
+
await service.deletePaymentMethod(CUSTOMER_ID, OLD_CARD_ID);
|
|
1535
|
+
|
|
1536
|
+
expect(stripe.customers.update).toHaveBeenCalledTimes(1);
|
|
1537
|
+
expect(stripe.customers.update).toHaveBeenCalledWith(CUSTOMER_ID, {
|
|
1538
|
+
invoice_settings: { default_payment_method: NEW_CARD_ID },
|
|
1539
|
+
});
|
|
1540
|
+
});
|
|
1541
|
+
|
|
1542
|
+
it("refuses to detach a payment method attached to another customer", async () => {
|
|
1543
|
+
stripe.paymentMethods.retrieve.mockResolvedValue(
|
|
1544
|
+
card(NEW_CARD_ID, "1111", OTHER_CUSTOMER_ID),
|
|
1545
|
+
);
|
|
1546
|
+
|
|
1547
|
+
await expect(
|
|
1548
|
+
service.deletePaymentMethod(CUSTOMER_ID, NEW_CARD_ID),
|
|
1549
|
+
).rejects.toThrow(
|
|
1550
|
+
new BadDataException("Payment method does not belong to this project"),
|
|
1551
|
+
);
|
|
1552
|
+
|
|
1553
|
+
expect(stripe.paymentMethods.detach).not.toHaveBeenCalled();
|
|
1554
|
+
expect(service.getPaymentMethods).not.toHaveBeenCalled();
|
|
1555
|
+
expect(stripe.customers.update).not.toHaveBeenCalled();
|
|
1556
|
+
expect(stripe.subscriptions.update).not.toHaveBeenCalled();
|
|
1557
|
+
});
|
|
1558
|
+
|
|
1559
|
+
it("refuses to detach a payment method Stripe does not know", async () => {
|
|
1560
|
+
stripe.paymentMethods.retrieve.mockRejectedValue(resourceMissing());
|
|
1561
|
+
|
|
1562
|
+
await expect(
|
|
1563
|
+
service.deletePaymentMethod(CUSTOMER_ID, "pm_does_not_exist"),
|
|
1564
|
+
).rejects.toThrow("Payment method does not belong to this project");
|
|
1565
|
+
|
|
1566
|
+
expect(stripe.paymentMethods.detach).not.toHaveBeenCalled();
|
|
1567
|
+
});
|
|
1568
|
+
|
|
1569
|
+
it("still refuses to delete the only payment method", async () => {
|
|
1570
|
+
paymentMethods = [
|
|
1571
|
+
{ id: OLD_CARD_ID, type: "visa", last4Digits: "4242", isDefault: true },
|
|
1572
|
+
];
|
|
1573
|
+
|
|
1574
|
+
await expect(
|
|
1575
|
+
service.deletePaymentMethod(CUSTOMER_ID, OLD_CARD_ID),
|
|
1576
|
+
).rejects.toThrow(
|
|
1577
|
+
Errors.BillingService.MIN_REQUIRED_PAYMENT_METHOD_NOT_MET,
|
|
1578
|
+
);
|
|
1579
|
+
|
|
1580
|
+
expect(stripe.paymentMethods.detach).not.toHaveBeenCalled();
|
|
1581
|
+
expect(stripe.customers.update).not.toHaveBeenCalled();
|
|
1582
|
+
});
|
|
1583
|
+
|
|
1584
|
+
it("repairs nothing when the detach itself fails", async () => {
|
|
1585
|
+
const failure: Error = providerError({ statusCode: 500 });
|
|
1586
|
+
stripe.paymentMethods.detach.mockRejectedValue(failure);
|
|
1587
|
+
|
|
1588
|
+
await expect(
|
|
1589
|
+
service.deletePaymentMethod(CUSTOMER_ID, OLD_CARD_ID),
|
|
1590
|
+
).rejects.toBe(failure);
|
|
1591
|
+
|
|
1592
|
+
expect(stripe.customers.update).not.toHaveBeenCalled();
|
|
1593
|
+
expect(stripe.subscriptions.list).not.toHaveBeenCalled();
|
|
1594
|
+
});
|
|
1595
|
+
|
|
1596
|
+
it("does not fail a completed delete when the new default cannot be set", async () => {
|
|
1597
|
+
stripe.customers.update.mockRejectedValue(
|
|
1598
|
+
providerError({ statusCode: 500 }),
|
|
1599
|
+
);
|
|
1600
|
+
|
|
1601
|
+
await expect(
|
|
1602
|
+
service.deletePaymentMethod(CUSTOMER_ID, OLD_CARD_ID),
|
|
1603
|
+
).resolves.toBeUndefined();
|
|
1604
|
+
|
|
1605
|
+
expect(stripe.paymentMethods.detach).toHaveBeenCalledWith(OLD_CARD_ID);
|
|
1606
|
+
expect(loggerError).toHaveBeenCalled();
|
|
1607
|
+
});
|
|
1608
|
+
|
|
1609
|
+
it("does not fail a completed delete when the subscriptions cannot be synced", async () => {
|
|
1610
|
+
stripe.subscriptions.update.mockRejectedValue(
|
|
1611
|
+
providerError({ statusCode: 400 }),
|
|
1612
|
+
);
|
|
1613
|
+
|
|
1614
|
+
await expect(
|
|
1615
|
+
service.deletePaymentMethod(CUSTOMER_ID, OLD_CARD_ID),
|
|
1616
|
+
).resolves.toBeUndefined();
|
|
1617
|
+
|
|
1618
|
+
expect(stripe.paymentMethods.detach).toHaveBeenCalledWith(OLD_CARD_ID);
|
|
1619
|
+
expect(stripe.customers.update).toHaveBeenCalledTimes(1);
|
|
1620
|
+
expect(loggerError).toHaveBeenCalled();
|
|
1621
|
+
});
|
|
1622
|
+
|
|
1623
|
+
it("refuses when billing is disabled, before any provider request", async () => {
|
|
1624
|
+
getJestSpyOn(service, "isBillingEnabled").mockReturnValue(false);
|
|
1625
|
+
|
|
1626
|
+
await expect(
|
|
1627
|
+
service.deletePaymentMethod(CUSTOMER_ID, OLD_CARD_ID),
|
|
1628
|
+
).rejects.toThrow(Errors.BillingService.BILLING_NOT_ENABLED);
|
|
1629
|
+
|
|
1630
|
+
expect(stripe.paymentMethods.retrieve).not.toHaveBeenCalled();
|
|
1631
|
+
expect(stripe.paymentMethods.detach).not.toHaveBeenCalled();
|
|
1632
|
+
});
|
|
1633
|
+
});
|
|
1634
|
+
});
|