@meyicloud/meyi-insight-server 1.0.0
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/dist/constants/incidentCategories.d.ts +18 -0
- package/dist/constants/incidentCategories.d.ts.map +1 -0
- package/dist/constants/incidentCategories.js +36 -0
- package/dist/constants/incidentCategories.js.map +1 -0
- package/dist/controllers/alert.controller.d.ts +12 -0
- package/dist/controllers/alert.controller.d.ts.map +1 -0
- package/dist/controllers/alert.controller.js +89 -0
- package/dist/controllers/alert.controller.js.map +1 -0
- package/dist/controllers/incident.controller.d.ts +16 -0
- package/dist/controllers/incident.controller.d.ts.map +1 -0
- package/dist/controllers/incident.controller.js +215 -0
- package/dist/controllers/incident.controller.js.map +1 -0
- package/dist/controllers/notification-provider.controller.d.ts +10 -0
- package/dist/controllers/notification-provider.controller.d.ts.map +1 -0
- package/dist/controllers/notification-provider.controller.js +59 -0
- package/dist/controllers/notification-provider.controller.js.map +1 -0
- package/dist/controllers/settings.controller.d.ts +7 -0
- package/dist/controllers/settings.controller.d.ts.map +1 -0
- package/dist/controllers/settings.controller.js +27 -0
- package/dist/controllers/settings.controller.js.map +1 -0
- package/dist/controllers/sop.controller.d.ts +11 -0
- package/dist/controllers/sop.controller.d.ts.map +1 -0
- package/dist/controllers/sop.controller.js +89 -0
- package/dist/controllers/sop.controller.js.map +1 -0
- package/dist/controllers/source.controller.d.ts +26 -0
- package/dist/controllers/source.controller.d.ts.map +1 -0
- package/dist/controllers/source.controller.js +333 -0
- package/dist/controllers/source.controller.js.map +1 -0
- package/dist/controllers/sourceDatadog.controller.d.ts +17 -0
- package/dist/controllers/sourceDatadog.controller.d.ts.map +1 -0
- package/dist/controllers/sourceDatadog.controller.js +169 -0
- package/dist/controllers/sourceDatadog.controller.js.map +1 -0
- package/dist/controllers/tenant.controller.d.ts +7 -0
- package/dist/controllers/tenant.controller.d.ts.map +1 -0
- package/dist/controllers/tenant.controller.js +33 -0
- package/dist/controllers/tenant.controller.js.map +1 -0
- package/dist/controllers/webhook.controller.d.ts +6 -0
- package/dist/controllers/webhook.controller.d.ts.map +1 -0
- package/dist/controllers/webhook.controller.js +83 -0
- package/dist/controllers/webhook.controller.js.map +1 -0
- package/dist/controllers/workflow.controller.d.ts +18 -0
- package/dist/controllers/workflow.controller.d.ts.map +1 -0
- package/dist/controllers/workflow.controller.js +118 -0
- package/dist/controllers/workflow.controller.js.map +1 -0
- package/dist/database/index.d.ts +7 -0
- package/dist/database/index.d.ts.map +1 -0
- package/dist/database/index.js +12 -0
- package/dist/database/index.js.map +1 -0
- package/dist/database/schema.d.ts +5358 -0
- package/dist/database/schema.d.ts.map +1 -0
- package/dist/database/schema.js +516 -0
- package/dist/database/schema.js.map +1 -0
- package/dist/features/sources/cloudtrail/controller.d.ts +38 -0
- package/dist/features/sources/cloudtrail/controller.d.ts.map +1 -0
- package/dist/features/sources/cloudtrail/controller.js +421 -0
- package/dist/features/sources/cloudtrail/controller.js.map +1 -0
- package/dist/features/sources/cloudtrail/routes.d.ts +6 -0
- package/dist/features/sources/cloudtrail/routes.d.ts.map +1 -0
- package/dist/features/sources/cloudtrail/routes.js +8 -0
- package/dist/features/sources/cloudtrail/routes.js.map +1 -0
- package/dist/features/sources/cloudtrail/schema.d.ts +2 -0
- package/dist/features/sources/cloudtrail/schema.d.ts.map +1 -0
- package/dist/features/sources/cloudtrail/schema.js +26 -0
- package/dist/features/sources/cloudtrail/schema.js.map +1 -0
- package/dist/features/sources/cloudtrail/stackTemplates.d.ts +3 -0
- package/dist/features/sources/cloudtrail/stackTemplates.d.ts.map +1 -0
- package/dist/features/sources/cloudtrail/stackTemplates.js +548 -0
- package/dist/features/sources/cloudtrail/stackTemplates.js.map +1 -0
- package/dist/features/sources/cloudtrail/template.d.ts +21 -0
- package/dist/features/sources/cloudtrail/template.d.ts.map +1 -0
- package/dist/features/sources/cloudtrail/template.js +1230 -0
- package/dist/features/sources/cloudtrail/template.js.map +1 -0
- package/dist/features/sources/cloudwatch/controller.d.ts +13 -0
- package/dist/features/sources/cloudwatch/controller.d.ts.map +1 -0
- package/dist/features/sources/cloudwatch/controller.js +514 -0
- package/dist/features/sources/cloudwatch/controller.js.map +1 -0
- package/dist/features/sources/cloudwatch/eventbridgeTemplate.d.ts +7 -0
- package/dist/features/sources/cloudwatch/eventbridgeTemplate.d.ts.map +1 -0
- package/dist/features/sources/cloudwatch/eventbridgeTemplate.js +230 -0
- package/dist/features/sources/cloudwatch/eventbridgeTemplate.js.map +1 -0
- package/dist/features/sources/cloudwatch/service.d.ts +50 -0
- package/dist/features/sources/cloudwatch/service.d.ts.map +1 -0
- package/dist/features/sources/cloudwatch/service.js +269 -0
- package/dist/features/sources/cloudwatch/service.js.map +1 -0
- package/dist/features/sources/cloudwatch/template.d.ts +26 -0
- package/dist/features/sources/cloudwatch/template.d.ts.map +1 -0
- package/dist/features/sources/cloudwatch/template.js +335 -0
- package/dist/features/sources/cloudwatch/template.js.map +1 -0
- package/dist/features/sources/cloudwatch/types.d.ts +26 -0
- package/dist/features/sources/cloudwatch/types.d.ts.map +1 -0
- package/dist/features/sources/cloudwatch/types.js +2 -0
- package/dist/features/sources/cloudwatch/types.js.map +1 -0
- package/dist/features/sources/grafana/controller.d.ts +18 -0
- package/dist/features/sources/grafana/controller.d.ts.map +1 -0
- package/dist/features/sources/grafana/controller.js +183 -0
- package/dist/features/sources/grafana/controller.js.map +1 -0
- package/dist/features/sources/grafana/routes.d.ts +6 -0
- package/dist/features/sources/grafana/routes.d.ts.map +1 -0
- package/dist/features/sources/grafana/routes.js +6 -0
- package/dist/features/sources/grafana/routes.js.map +1 -0
- package/dist/features/sources/grafana/schema.d.ts +2 -0
- package/dist/features/sources/grafana/schema.d.ts.map +1 -0
- package/dist/features/sources/grafana/schema.js +24 -0
- package/dist/features/sources/grafana/schema.js.map +1 -0
- package/dist/features/sources/grafana/service.d.ts +33 -0
- package/dist/features/sources/grafana/service.d.ts.map +1 -0
- package/dist/features/sources/grafana/service.js +215 -0
- package/dist/features/sources/grafana/service.js.map +1 -0
- package/dist/features/sources/index.d.ts +29 -0
- package/dist/features/sources/index.d.ts.map +1 -0
- package/dist/features/sources/index.js +47 -0
- package/dist/features/sources/index.js.map +1 -0
- package/dist/features/sources/observability/controller.d.ts +6 -0
- package/dist/features/sources/observability/controller.d.ts.map +1 -0
- package/dist/features/sources/observability/controller.js +16 -0
- package/dist/features/sources/observability/controller.js.map +1 -0
- package/dist/features/sources/observability/routes.d.ts +4 -0
- package/dist/features/sources/observability/routes.d.ts.map +1 -0
- package/dist/features/sources/observability/routes.js +8 -0
- package/dist/features/sources/observability/routes.js.map +1 -0
- package/dist/features/sources/observability/schema.d.ts +3 -0
- package/dist/features/sources/observability/schema.d.ts.map +1 -0
- package/dist/features/sources/observability/schema.js +44 -0
- package/dist/features/sources/observability/schema.js.map +1 -0
- package/dist/features/sources/observability/service.d.ts +36 -0
- package/dist/features/sources/observability/service.d.ts.map +1 -0
- package/dist/features/sources/observability/service.js +127 -0
- package/dist/features/sources/observability/service.js.map +1 -0
- package/dist/features/sources/prometheus/controller.d.ts +9 -0
- package/dist/features/sources/prometheus/controller.d.ts.map +1 -0
- package/dist/features/sources/prometheus/controller.js +359 -0
- package/dist/features/sources/prometheus/controller.js.map +1 -0
- package/dist/features/sources/prometheus/templates.d.ts +18 -0
- package/dist/features/sources/prometheus/templates.d.ts.map +1 -0
- package/dist/features/sources/prometheus/templates.js +244 -0
- package/dist/features/sources/prometheus/templates.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/migrations/0007_pipeline_yaml_definitions.d.ts +3 -0
- package/dist/migrations/0007_pipeline_yaml_definitions.d.ts.map +1 -0
- package/dist/migrations/0007_pipeline_yaml_definitions.js +19 -0
- package/dist/migrations/0007_pipeline_yaml_definitions.js.map +1 -0
- package/dist/migrations/0008_tenant_isolation.d.ts +3 -0
- package/dist/migrations/0008_tenant_isolation.d.ts.map +1 -0
- package/dist/migrations/0008_tenant_isolation.js +42 -0
- package/dist/migrations/0008_tenant_isolation.js.map +1 -0
- package/dist/migrations/run.d.ts +6 -0
- package/dist/migrations/run.d.ts.map +1 -0
- package/dist/migrations/run.js +1262 -0
- package/dist/migrations/run.js.map +1 -0
- package/dist/models/alarm-group.model.d.ts +42 -0
- package/dist/models/alarm-group.model.d.ts.map +1 -0
- package/dist/models/alarm-group.model.js +98 -0
- package/dist/models/alarm-group.model.js.map +1 -0
- package/dist/models/alert.model.d.ts +54 -0
- package/dist/models/alert.model.d.ts.map +1 -0
- package/dist/models/alert.model.js +119 -0
- package/dist/models/alert.model.js.map +1 -0
- package/dist/models/dedup-config.model.d.ts +53 -0
- package/dist/models/dedup-config.model.d.ts.map +1 -0
- package/dist/models/dedup-config.model.js +157 -0
- package/dist/models/dedup-config.model.js.map +1 -0
- package/dist/models/grouping-config.model.d.ts +70 -0
- package/dist/models/grouping-config.model.d.ts.map +1 -0
- package/dist/models/grouping-config.model.js +174 -0
- package/dist/models/grouping-config.model.js.map +1 -0
- package/dist/models/incident-comment.model.d.ts +14 -0
- package/dist/models/incident-comment.model.d.ts.map +1 -0
- package/dist/models/incident-comment.model.js +38 -0
- package/dist/models/incident-comment.model.js.map +1 -0
- package/dist/models/incident-event.model.d.ts +16 -0
- package/dist/models/incident-event.model.d.ts.map +1 -0
- package/dist/models/incident-event.model.js +31 -0
- package/dist/models/incident-event.model.js.map +1 -0
- package/dist/models/incident.model.d.ts +47 -0
- package/dist/models/incident.model.d.ts.map +1 -0
- package/dist/models/incident.model.js +201 -0
- package/dist/models/incident.model.js.map +1 -0
- package/dist/models/normalization-config.model.d.ts +44 -0
- package/dist/models/normalization-config.model.d.ts.map +1 -0
- package/dist/models/normalization-config.model.js +153 -0
- package/dist/models/normalization-config.model.js.map +1 -0
- package/dist/models/notification-provider.model.d.ts +12 -0
- package/dist/models/notification-provider.model.d.ts.map +1 -0
- package/dist/models/notification-provider.model.js +48 -0
- package/dist/models/notification-provider.model.js.map +1 -0
- package/dist/models/pipeline-event.model.d.ts +15 -0
- package/dist/models/pipeline-event.model.d.ts.map +1 -0
- package/dist/models/pipeline-event.model.js +32 -0
- package/dist/models/pipeline-event.model.js.map +1 -0
- package/dist/models/settings.model.d.ts +8 -0
- package/dist/models/settings.model.d.ts.map +1 -0
- package/dist/models/settings.model.js +30 -0
- package/dist/models/settings.model.js.map +1 -0
- package/dist/models/sop.model.d.ts +58 -0
- package/dist/models/sop.model.d.ts.map +1 -0
- package/dist/models/sop.model.js +138 -0
- package/dist/models/sop.model.js.map +1 -0
- package/dist/models/source.model.d.ts +177 -0
- package/dist/models/source.model.d.ts.map +1 -0
- package/dist/models/source.model.js +794 -0
- package/dist/models/source.model.js.map +1 -0
- package/dist/models/tenant.model.d.ts +13 -0
- package/dist/models/tenant.model.d.ts.map +1 -0
- package/dist/models/tenant.model.js +28 -0
- package/dist/models/tenant.model.js.map +1 -0
- package/dist/models/workflow.model.d.ts +36 -0
- package/dist/models/workflow.model.d.ts.map +1 -0
- package/dist/models/workflow.model.js +136 -0
- package/dist/models/workflow.model.js.map +1 -0
- package/dist/pipeline/AlarmPipelineWorker.d.ts +18 -0
- package/dist/pipeline/AlarmPipelineWorker.d.ts.map +1 -0
- package/dist/pipeline/AlarmPipelineWorker.js +342 -0
- package/dist/pipeline/AlarmPipelineWorker.js.map +1 -0
- package/dist/pipeline/CanonicalAlarm.d.ts +59 -0
- package/dist/pipeline/CanonicalAlarm.d.ts.map +1 -0
- package/dist/pipeline/CanonicalAlarm.js +81 -0
- package/dist/pipeline/CanonicalAlarm.js.map +1 -0
- package/dist/pipeline/DedupService.d.ts +29 -0
- package/dist/pipeline/DedupService.d.ts.map +1 -0
- package/dist/pipeline/DedupService.js +172 -0
- package/dist/pipeline/DedupService.js.map +1 -0
- package/dist/pipeline/GroupFlushWorker.d.ts +16 -0
- package/dist/pipeline/GroupFlushWorker.d.ts.map +1 -0
- package/dist/pipeline/GroupFlushWorker.js +196 -0
- package/dist/pipeline/GroupFlushWorker.js.map +1 -0
- package/dist/pipeline/GroupingService.d.ts +27 -0
- package/dist/pipeline/GroupingService.d.ts.map +1 -0
- package/dist/pipeline/GroupingService.js +338 -0
- package/dist/pipeline/GroupingService.js.map +1 -0
- package/dist/pipeline/NormalizationRuleEngine.d.ts +5 -0
- package/dist/pipeline/NormalizationRuleEngine.d.ts.map +1 -0
- package/dist/pipeline/NormalizationRuleEngine.js +86 -0
- package/dist/pipeline/NormalizationRuleEngine.js.map +1 -0
- package/dist/pipeline/NormalizationService.d.ts +29 -0
- package/dist/pipeline/NormalizationService.d.ts.map +1 -0
- package/dist/pipeline/NormalizationService.js +275 -0
- package/dist/pipeline/NormalizationService.js.map +1 -0
- package/dist/pipeline/alarmQueue.d.ts +66 -0
- package/dist/pipeline/alarmQueue.d.ts.map +1 -0
- package/dist/pipeline/alarmQueue.js +254 -0
- package/dist/pipeline/alarmQueue.js.map +1 -0
- package/dist/pipeline/defaults/ensureDefaults.d.ts +3 -0
- package/dist/pipeline/defaults/ensureDefaults.d.ts.map +1 -0
- package/dist/pipeline/defaults/ensureDefaults.js +124 -0
- package/dist/pipeline/defaults/ensureDefaults.js.map +1 -0
- package/dist/pipeline/defaults/pipelineDefaults.d.ts +13 -0
- package/dist/pipeline/defaults/pipelineDefaults.d.ts.map +1 -0
- package/dist/pipeline/defaults/pipelineDefaults.js +266 -0
- package/dist/pipeline/defaults/pipelineDefaults.js.map +1 -0
- package/dist/pipeline/yaml/DedupYaml.d.ts +33 -0
- package/dist/pipeline/yaml/DedupYaml.d.ts.map +1 -0
- package/dist/pipeline/yaml/DedupYaml.js +25 -0
- package/dist/pipeline/yaml/DedupYaml.js.map +1 -0
- package/dist/pipeline/yaml/GroupingYaml.d.ts +49 -0
- package/dist/pipeline/yaml/GroupingYaml.d.ts.map +1 -0
- package/dist/pipeline/yaml/GroupingYaml.js +39 -0
- package/dist/pipeline/yaml/GroupingYaml.js.map +1 -0
- package/dist/pipeline/yaml/NormalizationYaml.d.ts +54 -0
- package/dist/pipeline/yaml/NormalizationYaml.d.ts.map +1 -0
- package/dist/pipeline/yaml/NormalizationYaml.js +23 -0
- package/dist/pipeline/yaml/NormalizationYaml.js.map +1 -0
- package/dist/pipeline/yaml/pipelineYaml.d.ts +11 -0
- package/dist/pipeline/yaml/pipelineYaml.d.ts.map +1 -0
- package/dist/pipeline/yaml/pipelineYaml.js +49 -0
- package/dist/pipeline/yaml/pipelineYaml.js.map +1 -0
- package/dist/realtime/events.d.ts +11 -0
- package/dist/realtime/events.d.ts.map +1 -0
- package/dist/realtime/events.js +21 -0
- package/dist/realtime/events.js.map +1 -0
- package/dist/routes/alert.routes.d.ts +4 -0
- package/dist/routes/alert.routes.d.ts.map +1 -0
- package/dist/routes/alert.routes.js +15 -0
- package/dist/routes/alert.routes.js.map +1 -0
- package/dist/routes/dedup-config.routes.d.ts +4 -0
- package/dist/routes/dedup-config.routes.d.ts.map +1 -0
- package/dist/routes/dedup-config.routes.js +82 -0
- package/dist/routes/dedup-config.routes.js.map +1 -0
- package/dist/routes/grouping-config.routes.d.ts +4 -0
- package/dist/routes/grouping-config.routes.d.ts.map +1 -0
- package/dist/routes/grouping-config.routes.js +82 -0
- package/dist/routes/grouping-config.routes.js.map +1 -0
- package/dist/routes/incident.routes.d.ts +4 -0
- package/dist/routes/incident.routes.d.ts.map +1 -0
- package/dist/routes/incident.routes.js +21 -0
- package/dist/routes/incident.routes.js.map +1 -0
- package/dist/routes/index.d.ts +47 -0
- package/dist/routes/index.d.ts.map +1 -0
- package/dist/routes/index.js +83 -0
- package/dist/routes/index.js.map +1 -0
- package/dist/routes/normalization-config.routes.d.ts +4 -0
- package/dist/routes/normalization-config.routes.d.ts.map +1 -0
- package/dist/routes/normalization-config.routes.js +199 -0
- package/dist/routes/normalization-config.routes.js.map +1 -0
- package/dist/routes/notification-provider.routes.d.ts +4 -0
- package/dist/routes/notification-provider.routes.d.ts.map +1 -0
- package/dist/routes/notification-provider.routes.js +13 -0
- package/dist/routes/notification-provider.routes.js.map +1 -0
- package/dist/routes/pipeline.routes.d.ts +8 -0
- package/dist/routes/pipeline.routes.d.ts.map +1 -0
- package/dist/routes/pipeline.routes.js +243 -0
- package/dist/routes/pipeline.routes.js.map +1 -0
- package/dist/routes/settings.routes.d.ts +4 -0
- package/dist/routes/settings.routes.d.ts.map +1 -0
- package/dist/routes/settings.routes.js +10 -0
- package/dist/routes/settings.routes.js.map +1 -0
- package/dist/routes/sop.routes.d.ts +4 -0
- package/dist/routes/sop.routes.d.ts.map +1 -0
- package/dist/routes/sop.routes.js +14 -0
- package/dist/routes/sop.routes.js.map +1 -0
- package/dist/routes/source.routes.d.ts +9 -0
- package/dist/routes/source.routes.d.ts.map +1 -0
- package/dist/routes/source.routes.js +31 -0
- package/dist/routes/source.routes.js.map +1 -0
- package/dist/routes/tenant.routes.d.ts +4 -0
- package/dist/routes/tenant.routes.d.ts.map +1 -0
- package/dist/routes/tenant.routes.js +10 -0
- package/dist/routes/tenant.routes.js.map +1 -0
- package/dist/routes/workflow.routes.d.ts +4 -0
- package/dist/routes/workflow.routes.d.ts.map +1 -0
- package/dist/routes/workflow.routes.js +18 -0
- package/dist/routes/workflow.routes.js.map +1 -0
- package/dist/server.d.ts +22 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +76 -0
- package/dist/server.js.map +1 -0
- package/dist/service.d.ts +159 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/service.js +156 -0
- package/dist/service.js.map +1 -0
- package/dist/services/alert.service.d.ts +76 -0
- package/dist/services/alert.service.d.ts.map +1 -0
- package/dist/services/alert.service.js +688 -0
- package/dist/services/alert.service.js.map +1 -0
- package/dist/services/connector.service.d.ts +65 -0
- package/dist/services/connector.service.d.ts.map +1 -0
- package/dist/services/connector.service.js +28 -0
- package/dist/services/connector.service.js.map +1 -0
- package/dist/services/incident.service.d.ts +108 -0
- package/dist/services/incident.service.d.ts.map +1 -0
- package/dist/services/incident.service.js +325 -0
- package/dist/services/incident.service.js.map +1 -0
- package/dist/services/notification-provider.service.d.ts +12 -0
- package/dist/services/notification-provider.service.d.ts.map +1 -0
- package/dist/services/notification-provider.service.js +25 -0
- package/dist/services/notification-provider.service.js.map +1 -0
- package/dist/services/settings.service.d.ts +8 -0
- package/dist/services/settings.service.d.ts.map +1 -0
- package/dist/services/settings.service.js +14 -0
- package/dist/services/settings.service.js.map +1 -0
- package/dist/services/sop.service.d.ts +60 -0
- package/dist/services/sop.service.d.ts.map +1 -0
- package/dist/services/sop.service.js +66 -0
- package/dist/services/sop.service.js.map +1 -0
- package/dist/services/source.service.d.ts +162 -0
- package/dist/services/source.service.d.ts.map +1 -0
- package/dist/services/source.service.js +124 -0
- package/dist/services/source.service.js.map +1 -0
- package/dist/services/tenant.service.d.ts +11 -0
- package/dist/services/tenant.service.d.ts.map +1 -0
- package/dist/services/tenant.service.js +22 -0
- package/dist/services/tenant.service.js.map +1 -0
- package/dist/services/workflow.service.d.ts +32 -0
- package/dist/services/workflow.service.d.ts.map +1 -0
- package/dist/services/workflow.service.js +291 -0
- package/dist/services/workflow.service.js.map +1 -0
- package/dist/standalone.d.ts +2 -0
- package/dist/standalone.d.ts.map +1 -0
- package/dist/standalone.js +55 -0
- package/dist/standalone.js.map +1 -0
- package/dist/tenancy.d.ts +5 -0
- package/dist/tenancy.d.ts.map +1 -0
- package/dist/tenancy.js +35 -0
- package/dist/tenancy.js.map +1 -0
- package/dist/utils/notificationTemplates.d.ts +98 -0
- package/dist/utils/notificationTemplates.d.ts.map +1 -0
- package/dist/utils/notificationTemplates.js +227 -0
- package/dist/utils/notificationTemplates.js.map +1 -0
- package/dist/utils/secretCrypto.d.ts +3 -0
- package/dist/utils/secretCrypto.d.ts.map +1 -0
- package/dist/utils/secretCrypto.js +40 -0
- package/dist/utils/secretCrypto.js.map +1 -0
- package/dist/utils/workflowYaml.d.ts +53 -0
- package/dist/utils/workflowYaml.d.ts.map +1 -0
- package/dist/utils/workflowYaml.js +269 -0
- package/dist/utils/workflowYaml.js.map +1 -0
- package/package.json +73 -0
|
@@ -0,0 +1,794 @@
|
|
|
1
|
+
import { and, count, desc, eq, ilike, inArray, sql } from "drizzle-orm";
|
|
2
|
+
import { ensureSourcePipelineDefaults } from "../pipeline/defaults/ensureDefaults.js";
|
|
3
|
+
const DEFAULT_TOKEN_TTL_DAYS_RAW = Number.parseInt(process.env.INSIGHT_WEBHOOK_TOKEN_DEFAULT_DAYS || "30", 10);
|
|
4
|
+
const DEFAULT_TOKEN_TTL_DAYS = Number.isFinite(DEFAULT_TOKEN_TTL_DAYS_RAW) && DEFAULT_TOKEN_TTL_DAYS_RAW > 0
|
|
5
|
+
? DEFAULT_TOKEN_TTL_DAYS_RAW
|
|
6
|
+
: 30;
|
|
7
|
+
function parseTtlDays(value) {
|
|
8
|
+
const parsed = Number.parseInt(String(value), 10);
|
|
9
|
+
if (!Number.isFinite(parsed) || parsed <= 0)
|
|
10
|
+
return DEFAULT_TOKEN_TTL_DAYS;
|
|
11
|
+
return parsed;
|
|
12
|
+
}
|
|
13
|
+
function buildExpiresAt(days) {
|
|
14
|
+
const expiresAt = new Date();
|
|
15
|
+
expiresAt.setDate(expiresAt.getDate() + parseTtlDays(days));
|
|
16
|
+
return expiresAt;
|
|
17
|
+
}
|
|
18
|
+
function tokenPolicyForRow(row) {
|
|
19
|
+
const mode = row?.webhookTokenNeverExpires ? "unlimited" : "expires";
|
|
20
|
+
return {
|
|
21
|
+
mode,
|
|
22
|
+
expiresAt: mode === "unlimited" ? null : row?.webhookTokenExpiresAt ?? null,
|
|
23
|
+
defaultTtlDays: DEFAULT_TOKEN_TTL_DAYS,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export class SourceModel {
|
|
27
|
+
db;
|
|
28
|
+
tbl;
|
|
29
|
+
alertsTbl;
|
|
30
|
+
cloudWatchSetupTbl;
|
|
31
|
+
grafanaSetupTbl;
|
|
32
|
+
prometheusSetupTbl;
|
|
33
|
+
healthTbl;
|
|
34
|
+
webhookFailureLogsTbl;
|
|
35
|
+
cloudTrailSetupTbl;
|
|
36
|
+
constructor(db, tbl, alertsTbl, cloudWatchSetupTbl, grafanaSetupTbl, prometheusSetupTbl, healthTbl, webhookFailureLogsTbl, cloudTrailSetupTbl) {
|
|
37
|
+
this.db = db;
|
|
38
|
+
this.tbl = tbl;
|
|
39
|
+
this.alertsTbl = alertsTbl;
|
|
40
|
+
this.cloudWatchSetupTbl = cloudWatchSetupTbl;
|
|
41
|
+
this.grafanaSetupTbl = grafanaSetupTbl;
|
|
42
|
+
this.prometheusSetupTbl = prometheusSetupTbl;
|
|
43
|
+
this.healthTbl = healthTbl;
|
|
44
|
+
this.webhookFailureLogsTbl = webhookFailureLogsTbl;
|
|
45
|
+
this.cloudTrailSetupTbl = cloudTrailSetupTbl;
|
|
46
|
+
}
|
|
47
|
+
mergeHealth(row, health) {
|
|
48
|
+
if (!row)
|
|
49
|
+
return row;
|
|
50
|
+
return {
|
|
51
|
+
...row,
|
|
52
|
+
deliveryStatus: health?.deliveryStatus ?? "unknown",
|
|
53
|
+
lastWebhookReceivedAt: health?.lastWebhookReceivedAt ?? null,
|
|
54
|
+
lastSuccessfulWebhookAt: health?.lastSuccessfulWebhookAt ?? null,
|
|
55
|
+
lastFailedWebhookAt: health?.lastFailedWebhookAt ?? null,
|
|
56
|
+
lastErrorCode: health?.lastErrorCode ?? null,
|
|
57
|
+
lastErrorMessage: health?.lastErrorMessage ?? null,
|
|
58
|
+
lastAlertId: health?.lastAlertId ?? null,
|
|
59
|
+
webhookSuccessCount: Number(health?.successCount ?? 0),
|
|
60
|
+
webhookFailureCount: Number(health?.failureCount ?? 0),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
async findHealth(sourceId) {
|
|
64
|
+
if (!this.healthTbl)
|
|
65
|
+
return null;
|
|
66
|
+
const [row] = await this.db
|
|
67
|
+
.select()
|
|
68
|
+
.from(this.healthTbl)
|
|
69
|
+
.where(eq(this.healthTbl.sourceId, sourceId))
|
|
70
|
+
.limit(1);
|
|
71
|
+
return row ?? null;
|
|
72
|
+
}
|
|
73
|
+
async findHealthRows(sourceIds) {
|
|
74
|
+
if (!this.healthTbl || sourceIds.length === 0)
|
|
75
|
+
return {};
|
|
76
|
+
const rows = await this.db
|
|
77
|
+
.select()
|
|
78
|
+
.from(this.healthTbl)
|
|
79
|
+
.where(inArray(this.healthTbl.sourceId, sourceIds));
|
|
80
|
+
return Object.fromEntries(rows.map((row) => [String(row.sourceId), row]));
|
|
81
|
+
}
|
|
82
|
+
mergeCloudWatchSetup(row, setup) {
|
|
83
|
+
if (!row)
|
|
84
|
+
return row;
|
|
85
|
+
const isCloudWatch = String(row.type || "").toLowerCase() === "cloudwatch";
|
|
86
|
+
if (!isCloudWatch && !setup)
|
|
87
|
+
return row;
|
|
88
|
+
return {
|
|
89
|
+
...row,
|
|
90
|
+
...(setup
|
|
91
|
+
? {
|
|
92
|
+
awsAccessKeyId: setup.awsAccessKeyId,
|
|
93
|
+
awsSecretAccessKey: setup.awsSecretAccessKey,
|
|
94
|
+
awsSessionToken: setup.awsSessionToken,
|
|
95
|
+
awsRegion: setup.awsRegion,
|
|
96
|
+
awsStackName: setup.awsStackName,
|
|
97
|
+
awsLambdaName: setup.awsLambdaName,
|
|
98
|
+
awsAlarmNamePrefix: setup.awsAlarmNamePrefix,
|
|
99
|
+
awsSelectedAlarmNames: setup.awsSelectedAlarmNames ?? [],
|
|
100
|
+
awsSelectedMetricKeys: setup.awsSelectedMetricKeys ?? [],
|
|
101
|
+
awsDeploymentStatus: setup.awsDeploymentStatus ?? "not_started",
|
|
102
|
+
awsDeploymentStatusReason: setup.awsDeploymentStatusReason,
|
|
103
|
+
awsStackId: setup.awsStackId,
|
|
104
|
+
}
|
|
105
|
+
: {
|
|
106
|
+
awsSelectedAlarmNames: [],
|
|
107
|
+
awsSelectedMetricKeys: [],
|
|
108
|
+
awsDeploymentStatus: "not_started",
|
|
109
|
+
awsDeploymentStatusReason: null,
|
|
110
|
+
}),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
async findCloudWatchSetup(sourceId) {
|
|
114
|
+
if (!this.cloudWatchSetupTbl)
|
|
115
|
+
return null;
|
|
116
|
+
const [row] = await this.db
|
|
117
|
+
.select()
|
|
118
|
+
.from(this.cloudWatchSetupTbl)
|
|
119
|
+
.where(eq(this.cloudWatchSetupTbl.sourceId, sourceId))
|
|
120
|
+
.limit(1);
|
|
121
|
+
return row ?? null;
|
|
122
|
+
}
|
|
123
|
+
async findCloudWatchSetups(sourceIds) {
|
|
124
|
+
if (!this.cloudWatchSetupTbl || sourceIds.length === 0)
|
|
125
|
+
return {};
|
|
126
|
+
const rows = await this.db
|
|
127
|
+
.select()
|
|
128
|
+
.from(this.cloudWatchSetupTbl)
|
|
129
|
+
.where(inArray(this.cloudWatchSetupTbl.sourceId, sourceIds));
|
|
130
|
+
return Object.fromEntries(rows.map((row) => [String(row.sourceId), row]));
|
|
131
|
+
}
|
|
132
|
+
mergeCloudTrailSetup(row, setup) {
|
|
133
|
+
if (!row)
|
|
134
|
+
return row;
|
|
135
|
+
const isCloudTrail = String(row.type || "").toLowerCase() === "cloudtrail";
|
|
136
|
+
if (!isCloudTrail && !setup)
|
|
137
|
+
return row;
|
|
138
|
+
return {
|
|
139
|
+
...row,
|
|
140
|
+
...(setup
|
|
141
|
+
? {
|
|
142
|
+
awsRegion: setup.awsRegion,
|
|
143
|
+
awsStackName: setup.awsStackName,
|
|
144
|
+
awsCreateNewTrail: setup.awsCreateNewTrail ?? true,
|
|
145
|
+
awsDeploymentStatus: setup.awsDeploymentStatus ?? "not_started",
|
|
146
|
+
awsDeploymentStatusReason: setup.awsDeploymentStatusReason,
|
|
147
|
+
awsStackId: setup.awsStackId,
|
|
148
|
+
awsDeploymentMode: setup.awsDeploymentMode,
|
|
149
|
+
awsTargetOUs: setup.awsTargetOUs,
|
|
150
|
+
awsTargetAccounts: setup.awsTargetAccounts,
|
|
151
|
+
awsTargetRegions: setup.awsTargetRegions,
|
|
152
|
+
}
|
|
153
|
+
: {
|
|
154
|
+
awsCreateNewTrail: true,
|
|
155
|
+
awsDeploymentStatus: "not_started",
|
|
156
|
+
awsDeploymentStatusReason: null,
|
|
157
|
+
awsDeploymentMode: "Organizations",
|
|
158
|
+
}),
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
async findCloudTrailSetup(sourceId) {
|
|
162
|
+
if (!this.cloudTrailSetupTbl)
|
|
163
|
+
return null;
|
|
164
|
+
const [row] = await this.db
|
|
165
|
+
.select()
|
|
166
|
+
.from(this.cloudTrailSetupTbl)
|
|
167
|
+
.where(eq(this.cloudTrailSetupTbl.sourceId, sourceId))
|
|
168
|
+
.limit(1);
|
|
169
|
+
return row ?? null;
|
|
170
|
+
}
|
|
171
|
+
async findCloudTrailSetups(sourceIds) {
|
|
172
|
+
if (!this.cloudTrailSetupTbl || sourceIds.length === 0)
|
|
173
|
+
return {};
|
|
174
|
+
const rows = await this.db
|
|
175
|
+
.select()
|
|
176
|
+
.from(this.cloudTrailSetupTbl)
|
|
177
|
+
.where(inArray(this.cloudTrailSetupTbl.sourceId, sourceIds));
|
|
178
|
+
return Object.fromEntries(rows.map((row) => [String(row.sourceId), row]));
|
|
179
|
+
}
|
|
180
|
+
mergeGrafanaSetup(row, setup) {
|
|
181
|
+
if (!row || String(row.type || "").toLowerCase() !== "grafana")
|
|
182
|
+
return row;
|
|
183
|
+
return {
|
|
184
|
+
...row,
|
|
185
|
+
grafanaBaseUrl: setup?.grafanaBaseUrl ?? null,
|
|
186
|
+
grafanaContactPointName: setup?.grafanaContactPointName ?? null,
|
|
187
|
+
grafanaAccountTokenEncrypted: setup?.grafanaAccountTokenEncrypted ?? null,
|
|
188
|
+
hasGrafanaAccountToken: Boolean(setup?.grafanaAccountTokenEncrypted),
|
|
189
|
+
grafanaAutoRoute: setup?.grafanaAutoRoute ?? false,
|
|
190
|
+
grafanaMatcherLabel: setup?.grafanaMatcherLabel ?? null,
|
|
191
|
+
grafanaMatcherValue: setup?.grafanaMatcherValue ?? null,
|
|
192
|
+
grafanaPolicyUpdated: setup?.grafanaPolicyUpdated ?? false,
|
|
193
|
+
grafanaSetupStatus: setup?.grafanaSetupStatus ?? "not_started",
|
|
194
|
+
grafanaSetupStatusReason: setup?.grafanaSetupStatusReason ?? null,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
mergePrometheusSetup(row, setup) {
|
|
198
|
+
if (!row || String(row.type || "").toLowerCase() !== "prometheus")
|
|
199
|
+
return row;
|
|
200
|
+
return {
|
|
201
|
+
...row,
|
|
202
|
+
prometheusEnvironment: setup?.prometheusEnvironment ?? null,
|
|
203
|
+
prometheusReceiverName: setup?.prometheusReceiverName ?? null,
|
|
204
|
+
prometheusBaseUrl: setup?.prometheusBaseUrl ?? null,
|
|
205
|
+
alertmanagerBaseUrl: setup?.alertmanagerBaseUrl ?? null,
|
|
206
|
+
prometheusSetupStatus: setup?.prometheusSetupStatus ?? "not_started",
|
|
207
|
+
prometheusSetupStatusReason: setup?.prometheusSetupStatusReason ?? null,
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
async findGrafanaSetup(sourceId) {
|
|
211
|
+
if (!this.grafanaSetupTbl)
|
|
212
|
+
return null;
|
|
213
|
+
const [row] = await this.db
|
|
214
|
+
.select()
|
|
215
|
+
.from(this.grafanaSetupTbl)
|
|
216
|
+
.where(eq(this.grafanaSetupTbl.sourceId, sourceId))
|
|
217
|
+
.limit(1);
|
|
218
|
+
return row ?? null;
|
|
219
|
+
}
|
|
220
|
+
async findPrometheusSetup(sourceId) {
|
|
221
|
+
if (!this.prometheusSetupTbl)
|
|
222
|
+
return null;
|
|
223
|
+
const [row] = await this.db
|
|
224
|
+
.select()
|
|
225
|
+
.from(this.prometheusSetupTbl)
|
|
226
|
+
.where(eq(this.prometheusSetupTbl.sourceId, sourceId))
|
|
227
|
+
.limit(1);
|
|
228
|
+
return row ?? null;
|
|
229
|
+
}
|
|
230
|
+
async findGrafanaSetups(sourceIds) {
|
|
231
|
+
if (!this.grafanaSetupTbl || sourceIds.length === 0)
|
|
232
|
+
return {};
|
|
233
|
+
const rows = await this.db
|
|
234
|
+
.select()
|
|
235
|
+
.from(this.grafanaSetupTbl)
|
|
236
|
+
.where(inArray(this.grafanaSetupTbl.sourceId, sourceIds));
|
|
237
|
+
return Object.fromEntries(rows.map((row) => [String(row.sourceId), row]));
|
|
238
|
+
}
|
|
239
|
+
async findPrometheusSetups(sourceIds) {
|
|
240
|
+
if (!this.prometheusSetupTbl || sourceIds.length === 0)
|
|
241
|
+
return {};
|
|
242
|
+
const rows = await this.db
|
|
243
|
+
.select()
|
|
244
|
+
.from(this.prometheusSetupTbl)
|
|
245
|
+
.where(inArray(this.prometheusSetupTbl.sourceId, sourceIds));
|
|
246
|
+
return Object.fromEntries(rows.map((row) => [String(row.sourceId), row]));
|
|
247
|
+
}
|
|
248
|
+
async assertUniqueName(name, excludeId, tenantId) {
|
|
249
|
+
const trimmed = String(name || "").trim();
|
|
250
|
+
if (!trimmed)
|
|
251
|
+
return;
|
|
252
|
+
const conditions = [sql `lower(${this.tbl.name}) = lower(${trimmed})`];
|
|
253
|
+
if (excludeId) {
|
|
254
|
+
conditions.push(sql `${this.tbl.id} <> ${excludeId}`);
|
|
255
|
+
}
|
|
256
|
+
if (tenantId) {
|
|
257
|
+
conditions.push(eq(this.tbl.tenantId, tenantId));
|
|
258
|
+
}
|
|
259
|
+
const [existing] = await this.db
|
|
260
|
+
.select({ id: this.tbl.id })
|
|
261
|
+
.from(this.tbl)
|
|
262
|
+
.where(and(...conditions))
|
|
263
|
+
.limit(1);
|
|
264
|
+
if (existing) {
|
|
265
|
+
throw new Error("Source name already exists");
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
async findById(id, tenantId) {
|
|
269
|
+
const conditions = [eq(this.tbl.id, id)];
|
|
270
|
+
if (tenantId)
|
|
271
|
+
conditions.push(eq(this.tbl.tenantId, tenantId));
|
|
272
|
+
const [row] = await this.db
|
|
273
|
+
.select()
|
|
274
|
+
.from(this.tbl)
|
|
275
|
+
.where(and(...conditions))
|
|
276
|
+
.limit(1);
|
|
277
|
+
if (!row)
|
|
278
|
+
return null;
|
|
279
|
+
const [cloudWatchSetup, grafanaSetup, prometheusSetup, cloudTrailSetup, health] = await Promise.all([
|
|
280
|
+
this.findCloudWatchSetup(row.id),
|
|
281
|
+
this.findGrafanaSetup(row.id),
|
|
282
|
+
this.findPrometheusSetup(row.id),
|
|
283
|
+
this.findCloudTrailSetup(row.id),
|
|
284
|
+
this.findHealth(row.id),
|
|
285
|
+
]);
|
|
286
|
+
return this.mergeHealth(this.mergeCloudTrailSetup(this.mergePrometheusSetup(this.mergeGrafanaSetup(this.mergeCloudWatchSetup(row, cloudWatchSetup), grafanaSetup), prometheusSetup), cloudTrailSetup), health);
|
|
287
|
+
}
|
|
288
|
+
async findByToken(token) {
|
|
289
|
+
const result = await this.validateWebhookToken(token);
|
|
290
|
+
return result.source;
|
|
291
|
+
}
|
|
292
|
+
async validateWebhookToken(token, authToken) {
|
|
293
|
+
const [row] = await this.db
|
|
294
|
+
.select()
|
|
295
|
+
.from(this.tbl)
|
|
296
|
+
.where(eq(this.tbl.webhookToken, token))
|
|
297
|
+
.limit(1);
|
|
298
|
+
if (!row)
|
|
299
|
+
return { source: null, reason: "NOT_FOUND" };
|
|
300
|
+
if (row.webhookAuthToken && row.webhookAuthToken !== authToken) {
|
|
301
|
+
return { source: null, reason: "UNAUTHORIZED", rejectedSource: row };
|
|
302
|
+
}
|
|
303
|
+
if (!row.isActive) {
|
|
304
|
+
return { source: null, reason: "INACTIVE", rejectedSource: row };
|
|
305
|
+
}
|
|
306
|
+
if (!row.webhookTokenNeverExpires) {
|
|
307
|
+
const expiresAt = row.webhookTokenExpiresAt ? new Date(row.webhookTokenExpiresAt) : null;
|
|
308
|
+
if (!expiresAt || Number.isNaN(expiresAt.getTime()) || expiresAt.getTime() <= Date.now()) {
|
|
309
|
+
return { source: null, reason: "EXPIRED", rejectedSource: row };
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
const [cloudWatchSetup, grafanaSetup, prometheusSetup, cloudTrailSetup, health] = await Promise.all([
|
|
313
|
+
this.findCloudWatchSetup(row.id),
|
|
314
|
+
this.findGrafanaSetup(row.id),
|
|
315
|
+
this.findPrometheusSetup(row.id),
|
|
316
|
+
this.findCloudTrailSetup(row.id),
|
|
317
|
+
this.findHealth(row.id),
|
|
318
|
+
]);
|
|
319
|
+
return {
|
|
320
|
+
source: this.mergeHealth(this.mergeCloudTrailSetup(this.mergePrometheusSetup(this.mergeGrafanaSetup(this.mergeCloudWatchSetup(row, cloudWatchSetup), grafanaSetup), prometheusSetup), cloudTrailSetup), health),
|
|
321
|
+
reason: null,
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
async list(params) {
|
|
325
|
+
const { page, limit } = params;
|
|
326
|
+
const offset = (page - 1) * limit;
|
|
327
|
+
const conditions = [];
|
|
328
|
+
if (params.search) {
|
|
329
|
+
conditions.push(ilike(this.tbl.name, `%${params.search}%`));
|
|
330
|
+
}
|
|
331
|
+
if (params.types?.length) {
|
|
332
|
+
conditions.push(inArray(this.tbl.type, params.types));
|
|
333
|
+
}
|
|
334
|
+
if (params.tenantId) {
|
|
335
|
+
conditions.push(eq(this.tbl.tenantId, params.tenantId));
|
|
336
|
+
}
|
|
337
|
+
const whereClause = conditions.length > 0 ? and(...conditions) : undefined;
|
|
338
|
+
let q = this.db
|
|
339
|
+
.select()
|
|
340
|
+
.from(this.tbl)
|
|
341
|
+
.$dynamic();
|
|
342
|
+
if (whereClause) {
|
|
343
|
+
q = q.where(whereClause);
|
|
344
|
+
}
|
|
345
|
+
const rows = await q.orderBy(desc(this.tbl.createdAt)).limit(limit).offset(offset);
|
|
346
|
+
let countQ = this.db.select({ value: count() }).from(this.tbl).$dynamic();
|
|
347
|
+
if (whereClause) {
|
|
348
|
+
countQ = countQ.where(whereClause);
|
|
349
|
+
}
|
|
350
|
+
const [{ value: total }] = await countQ;
|
|
351
|
+
const sourceIds = rows.map((r) => r.id).filter(Boolean);
|
|
352
|
+
let alertCountsBySourceId = {};
|
|
353
|
+
if (this.alertsTbl && sourceIds.length > 0) {
|
|
354
|
+
const counts = await this.db
|
|
355
|
+
.select({
|
|
356
|
+
sourceId: this.alertsTbl.sourceId,
|
|
357
|
+
value: count(),
|
|
358
|
+
})
|
|
359
|
+
.from(this.alertsTbl)
|
|
360
|
+
.where(inArray(this.alertsTbl.sourceId, sourceIds))
|
|
361
|
+
.groupBy(this.alertsTbl.sourceId);
|
|
362
|
+
alertCountsBySourceId = Object.fromEntries(counts
|
|
363
|
+
.filter((r) => r.sourceId)
|
|
364
|
+
.map((r) => [String(r.sourceId), Number(r.value || 0)]));
|
|
365
|
+
}
|
|
366
|
+
const [setupBySourceId, grafanaSetupBySourceId, prometheusSetupBySourceId, cloudTrailSetupBySourceId, healthBySourceId] = await Promise.all([
|
|
367
|
+
this.findCloudWatchSetups(sourceIds),
|
|
368
|
+
this.findGrafanaSetups(sourceIds),
|
|
369
|
+
this.findPrometheusSetups(sourceIds),
|
|
370
|
+
this.findCloudTrailSetups(sourceIds),
|
|
371
|
+
this.findHealthRows(sourceIds),
|
|
372
|
+
]);
|
|
373
|
+
const sources = rows.map((row) => ({
|
|
374
|
+
...this.mergeHealth(this.mergeCloudTrailSetup(this.mergePrometheusSetup(this.mergeGrafanaSetup(this.mergeCloudWatchSetup(row, setupBySourceId[String(row.id)]), grafanaSetupBySourceId[String(row.id)]), prometheusSetupBySourceId[String(row.id)]), cloudTrailSetupBySourceId[String(row.id)]), healthBySourceId[String(row.id)]),
|
|
375
|
+
webhookUrl: `/api/v1/insight/webhook/${row.webhookToken}`,
|
|
376
|
+
tokenPolicy: tokenPolicyForRow(row),
|
|
377
|
+
alertCount: alertCountsBySourceId[String(row.id)] ?? 0,
|
|
378
|
+
}));
|
|
379
|
+
return { sources, total: Number(total), page, limit };
|
|
380
|
+
}
|
|
381
|
+
async getOverview(id, tenantId) {
|
|
382
|
+
const source = await this.findById(id, tenantId);
|
|
383
|
+
if (!source)
|
|
384
|
+
return null;
|
|
385
|
+
let alarmsToday = 0;
|
|
386
|
+
let lastAlarm = null;
|
|
387
|
+
let errorCountLastHour = Number(source.webhookFailureCount ?? 0);
|
|
388
|
+
if (this.alertsTbl) {
|
|
389
|
+
const sinceToday = new Date();
|
|
390
|
+
sinceToday.setHours(0, 0, 0, 0);
|
|
391
|
+
const sinceHour = new Date(Date.now() - 60 * 60 * 1000);
|
|
392
|
+
const [[today], [last]] = await Promise.all([
|
|
393
|
+
this.db
|
|
394
|
+
.select({ value: count() })
|
|
395
|
+
.from(this.alertsTbl)
|
|
396
|
+
.where(and(eq(this.alertsTbl.sourceId, id), sql `${this.alertsTbl.createdAt} >= ${sinceToday}`)),
|
|
397
|
+
this.db
|
|
398
|
+
.select()
|
|
399
|
+
.from(this.alertsTbl)
|
|
400
|
+
.where(eq(this.alertsTbl.sourceId, id))
|
|
401
|
+
.orderBy(desc(this.alertsTbl.createdAt))
|
|
402
|
+
.limit(1),
|
|
403
|
+
]);
|
|
404
|
+
alarmsToday = Number(today?.value ?? 0);
|
|
405
|
+
lastAlarm = last ?? null;
|
|
406
|
+
if (this.webhookFailureLogsTbl) {
|
|
407
|
+
const [errors] = await this.db
|
|
408
|
+
.select({ value: count() })
|
|
409
|
+
.from(this.webhookFailureLogsTbl)
|
|
410
|
+
.where(and(eq(this.webhookFailureLogsTbl.sourceId, id), sql `${this.webhookFailureLogsTbl.createdAt} >= ${sinceHour}`));
|
|
411
|
+
errorCountLastHour = Number(errors?.value ?? 0);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
const weeklyRate = await this.getAlarmRate(id, 7);
|
|
415
|
+
return {
|
|
416
|
+
source,
|
|
417
|
+
summary: {
|
|
418
|
+
status: source.isActive ? "Active" : "Disabled",
|
|
419
|
+
lastAlarmAt: lastAlarm?.createdAt ?? source.lastWebhookReceivedAt ?? null,
|
|
420
|
+
alarmsToday,
|
|
421
|
+
errorsLastHour: errorCountLastHour,
|
|
422
|
+
weeklyRate,
|
|
423
|
+
webhookEndpoint: `/api/v1/insight/webhook/${source.webhookToken}`,
|
|
424
|
+
authTokenPreview: source.webhookAuthToken,
|
|
425
|
+
},
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
async getAlarmRate(id, days = 7) {
|
|
429
|
+
const labels = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
|
430
|
+
const start = new Date();
|
|
431
|
+
start.setDate(start.getDate() - (days - 1));
|
|
432
|
+
start.setHours(0, 0, 0, 0);
|
|
433
|
+
const buckets = Array.from({ length: days }, (_, index) => {
|
|
434
|
+
const date = new Date(start);
|
|
435
|
+
date.setDate(start.getDate() + index);
|
|
436
|
+
return { date, day: labels[date.getDay()], count: 0 };
|
|
437
|
+
});
|
|
438
|
+
if (!this.alertsTbl)
|
|
439
|
+
return buckets.map(({ day, count }) => ({ day, count }));
|
|
440
|
+
const rows = await this.db
|
|
441
|
+
.select({
|
|
442
|
+
day: sql `to_char(${this.alertsTbl.createdAt}, 'YYYY-MM-DD')`,
|
|
443
|
+
value: count(),
|
|
444
|
+
})
|
|
445
|
+
.from(this.alertsTbl)
|
|
446
|
+
.where(and(eq(this.alertsTbl.sourceId, id), sql `${this.alertsTbl.createdAt} >= ${start}`))
|
|
447
|
+
.groupBy(sql `to_char(${this.alertsTbl.createdAt}, 'YYYY-MM-DD')`);
|
|
448
|
+
const counts = Object.fromEntries(rows.map((row) => [String(row.day), Number(row.value ?? 0)]));
|
|
449
|
+
return buckets.map(({ date, day }) => ({
|
|
450
|
+
day,
|
|
451
|
+
count: counts[date.toISOString().slice(0, 10)] ?? 0,
|
|
452
|
+
}));
|
|
453
|
+
}
|
|
454
|
+
async listSourceAlarms(id, params, tenantId) {
|
|
455
|
+
const page = Math.max(1, params?.page ?? 1);
|
|
456
|
+
const limit = Math.min(100, params?.limit ?? 20);
|
|
457
|
+
const offset = (page - 1) * limit;
|
|
458
|
+
if (!this.alertsTbl)
|
|
459
|
+
return { alarms: [], total: 0, page, limit };
|
|
460
|
+
const conditions = [eq(this.alertsTbl.sourceId, id)];
|
|
461
|
+
if (tenantId)
|
|
462
|
+
conditions.push(eq(this.alertsTbl.tenantId, tenantId));
|
|
463
|
+
const whereClause = conditions.length > 1 ? and(...conditions) : conditions[0];
|
|
464
|
+
const alarms = await this.db
|
|
465
|
+
.select()
|
|
466
|
+
.from(this.alertsTbl)
|
|
467
|
+
.where(whereClause)
|
|
468
|
+
.orderBy(desc(this.alertsTbl.createdAt))
|
|
469
|
+
.limit(limit)
|
|
470
|
+
.offset(offset);
|
|
471
|
+
const [{ value: total }] = await this.db.select({ value: count() }).from(this.alertsTbl).where(whereClause);
|
|
472
|
+
return { alarms, total: Number(total), page, limit };
|
|
473
|
+
}
|
|
474
|
+
async listSourceLogs(id, params, tenantId) {
|
|
475
|
+
const page = Math.max(1, params?.page ?? 1);
|
|
476
|
+
const limit = Math.min(100, params?.limit ?? 20);
|
|
477
|
+
const offset = (page - 1) * limit;
|
|
478
|
+
const logs = [];
|
|
479
|
+
if (this.alertsTbl) {
|
|
480
|
+
const conditions = [eq(this.alertsTbl.sourceId, id)];
|
|
481
|
+
if (tenantId)
|
|
482
|
+
conditions.push(eq(this.alertsTbl.tenantId, tenantId));
|
|
483
|
+
const whereClause = conditions.length > 1 ? and(...conditions) : conditions[0];
|
|
484
|
+
const alertRows = await this.db
|
|
485
|
+
.select()
|
|
486
|
+
.from(this.alertsTbl)
|
|
487
|
+
.where(whereClause)
|
|
488
|
+
.orderBy(desc(this.alertsTbl.createdAt))
|
|
489
|
+
.limit(limit)
|
|
490
|
+
.offset(offset);
|
|
491
|
+
logs.push(...alertRows.map((alert) => ({
|
|
492
|
+
id: alert.id,
|
|
493
|
+
timestamp: alert.createdAt,
|
|
494
|
+
httpStatus: 200,
|
|
495
|
+
sourceIp: "52.94.12.40",
|
|
496
|
+
payloadSize: JSON.stringify(alert.additionalConfiguration ?? alert).length,
|
|
497
|
+
result: alert.status === "dismissed" ? "suppressed" : "normalised",
|
|
498
|
+
})));
|
|
499
|
+
}
|
|
500
|
+
if (this.webhookFailureLogsTbl && logs.length < limit) {
|
|
501
|
+
const failures = await this.db
|
|
502
|
+
.select()
|
|
503
|
+
.from(this.webhookFailureLogsTbl)
|
|
504
|
+
.where(eq(this.webhookFailureLogsTbl.sourceId, id))
|
|
505
|
+
.orderBy(desc(this.webhookFailureLogsTbl.createdAt))
|
|
506
|
+
.limit(limit - logs.length);
|
|
507
|
+
logs.push(...failures.map((failure) => ({
|
|
508
|
+
id: failure.id,
|
|
509
|
+
timestamp: failure.createdAt,
|
|
510
|
+
httpStatus: failure.errorCode === "UNAUTHORIZED" ? 401 : 400,
|
|
511
|
+
sourceIp: failure.requestIp ?? "unknown",
|
|
512
|
+
payloadSize: JSON.stringify(failure.payload ?? {}).length,
|
|
513
|
+
result: failure.errorCode ?? "DLQ",
|
|
514
|
+
})));
|
|
515
|
+
}
|
|
516
|
+
const filtered = params?.search
|
|
517
|
+
? logs.filter((log) => JSON.stringify(log).toLowerCase().includes(String(params.search).toLowerCase()))
|
|
518
|
+
: logs;
|
|
519
|
+
return { logs: filtered, total: filtered.length, page, limit };
|
|
520
|
+
}
|
|
521
|
+
async create(input) {
|
|
522
|
+
const name = input.name.trim();
|
|
523
|
+
await this.assertUniqueName(name, undefined, input.tenantId ?? null);
|
|
524
|
+
const webhookToken = crypto.randomUUID();
|
|
525
|
+
const webhookAuthToken = crypto.randomUUID().replace(/-/g, "") + crypto.randomUUID().replace(/-/g, "");
|
|
526
|
+
const mode = input.tokenPolicy?.mode === "unlimited" ? "unlimited" : "expires";
|
|
527
|
+
const ttlDays = parseTtlDays(input.tokenPolicy?.ttlDays);
|
|
528
|
+
const [row] = await this.db
|
|
529
|
+
.insert(this.tbl)
|
|
530
|
+
.values({
|
|
531
|
+
name,
|
|
532
|
+
type: input.type,
|
|
533
|
+
tenantId: input.tenantId ?? null,
|
|
534
|
+
webhookToken,
|
|
535
|
+
webhookAuthToken,
|
|
536
|
+
webhookTokenNeverExpires: mode === "unlimited",
|
|
537
|
+
webhookTokenExpiresAt: mode === "unlimited" ? null : buildExpiresAt(ttlDays),
|
|
538
|
+
isActive: true,
|
|
539
|
+
description: input.description ?? null,
|
|
540
|
+
})
|
|
541
|
+
.returning();
|
|
542
|
+
await ensureSourcePipelineDefaults(this.db, row.id, row.type, row.tenantId);
|
|
543
|
+
return row;
|
|
544
|
+
}
|
|
545
|
+
async update(id, data, tenantId) {
|
|
546
|
+
const existing = await this.findById(id, tenantId);
|
|
547
|
+
const oldName = existing?.name;
|
|
548
|
+
const updates = { updatedAt: new Date() };
|
|
549
|
+
if (data.name !== undefined) {
|
|
550
|
+
const name = data.name.trim();
|
|
551
|
+
await this.assertUniqueName(name, id, tenantId);
|
|
552
|
+
updates.name = name;
|
|
553
|
+
}
|
|
554
|
+
if (data.description !== undefined)
|
|
555
|
+
updates.description = data.description;
|
|
556
|
+
if (data.isActive !== undefined)
|
|
557
|
+
updates.isActive = data.isActive;
|
|
558
|
+
const updateConditions = [eq(this.tbl.id, id)];
|
|
559
|
+
if (tenantId)
|
|
560
|
+
updateConditions.push(eq(this.tbl.tenantId, tenantId));
|
|
561
|
+
await this.db
|
|
562
|
+
.update(this.tbl)
|
|
563
|
+
.set(updates)
|
|
564
|
+
.where(and(...updateConditions));
|
|
565
|
+
if (updates.name && oldName && updates.name !== oldName) {
|
|
566
|
+
try {
|
|
567
|
+
await this.db.execute(sql `UPDATE insight_alerts SET source_name = ${updates.name} WHERE source_id = ${id}`);
|
|
568
|
+
await this.db.execute(sql `UPDATE insight_incidents SET source = ${updates.name} WHERE source = ${oldName}`);
|
|
569
|
+
await this.db.execute(sql `UPDATE insight_sops SET source = ${updates.name} WHERE source = ${oldName}`);
|
|
570
|
+
}
|
|
571
|
+
catch (err) {
|
|
572
|
+
console.error("Failed to cascade source rename:", err);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
async rotateToken(id, tenantId) {
|
|
577
|
+
const existing = await this.findById(id, tenantId);
|
|
578
|
+
if (!existing)
|
|
579
|
+
throw new Error("Source not found");
|
|
580
|
+
const newToken = crypto.randomUUID();
|
|
581
|
+
const updates = {
|
|
582
|
+
webhookToken: newToken,
|
|
583
|
+
updatedAt: new Date(),
|
|
584
|
+
};
|
|
585
|
+
if (existing.webhookTokenNeverExpires) {
|
|
586
|
+
updates.webhookTokenNeverExpires = true;
|
|
587
|
+
updates.webhookTokenExpiresAt = null;
|
|
588
|
+
}
|
|
589
|
+
else {
|
|
590
|
+
updates.webhookTokenNeverExpires = false;
|
|
591
|
+
updates.webhookTokenExpiresAt = buildExpiresAt(DEFAULT_TOKEN_TTL_DAYS);
|
|
592
|
+
}
|
|
593
|
+
await this.db
|
|
594
|
+
.update(this.tbl)
|
|
595
|
+
.set(updates)
|
|
596
|
+
.where(eq(this.tbl.id, id));
|
|
597
|
+
const refreshed = await this.findById(id);
|
|
598
|
+
return {
|
|
599
|
+
webhookToken: newToken,
|
|
600
|
+
tokenPolicy: tokenPolicyForRow(refreshed),
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
async updateTokenPolicy(id, tokenPolicy, tenantId) {
|
|
604
|
+
const mode = tokenPolicy.mode === "unlimited" ? "unlimited" : "expires";
|
|
605
|
+
const ttlDays = parseTtlDays(tokenPolicy.ttlDays);
|
|
606
|
+
const updates = {
|
|
607
|
+
updatedAt: new Date(),
|
|
608
|
+
webhookTokenNeverExpires: mode === "unlimited",
|
|
609
|
+
webhookTokenExpiresAt: mode === "unlimited" ? null : buildExpiresAt(ttlDays),
|
|
610
|
+
};
|
|
611
|
+
const updateConditions = [eq(this.tbl.id, id)];
|
|
612
|
+
if (tenantId)
|
|
613
|
+
updateConditions.push(eq(this.tbl.tenantId, tenantId));
|
|
614
|
+
await this.db
|
|
615
|
+
.update(this.tbl)
|
|
616
|
+
.set(updates)
|
|
617
|
+
.where(and(...updateConditions));
|
|
618
|
+
const refreshed = await this.findById(id, tenantId);
|
|
619
|
+
return tokenPolicyForRow(refreshed);
|
|
620
|
+
}
|
|
621
|
+
async updateCloudWatchSetup(id, data, tenantId) {
|
|
622
|
+
const values = {
|
|
623
|
+
sourceId: id,
|
|
624
|
+
};
|
|
625
|
+
const updates = {
|
|
626
|
+
updatedAt: new Date(),
|
|
627
|
+
};
|
|
628
|
+
if (data.awsAccessKeyId !== undefined)
|
|
629
|
+
values.awsAccessKeyId = updates.awsAccessKeyId = data.awsAccessKeyId;
|
|
630
|
+
if (data.awsSecretAccessKey !== undefined)
|
|
631
|
+
values.awsSecretAccessKey = updates.awsSecretAccessKey = data.awsSecretAccessKey;
|
|
632
|
+
if (data.awsSessionToken !== undefined)
|
|
633
|
+
values.awsSessionToken = updates.awsSessionToken = data.awsSessionToken;
|
|
634
|
+
if (data.awsRegion !== undefined)
|
|
635
|
+
values.awsRegion = updates.awsRegion = data.awsRegion;
|
|
636
|
+
if (data.awsStackName !== undefined)
|
|
637
|
+
values.awsStackName = updates.awsStackName = data.awsStackName;
|
|
638
|
+
if (data.awsLambdaName !== undefined)
|
|
639
|
+
values.awsLambdaName = updates.awsLambdaName = data.awsLambdaName;
|
|
640
|
+
if (data.awsAlarmNamePrefix !== undefined)
|
|
641
|
+
values.awsAlarmNamePrefix = updates.awsAlarmNamePrefix = data.awsAlarmNamePrefix;
|
|
642
|
+
if (data.awsSelectedAlarmNames !== undefined)
|
|
643
|
+
values.awsSelectedAlarmNames = updates.awsSelectedAlarmNames = data.awsSelectedAlarmNames;
|
|
644
|
+
if (data.awsSelectedMetricKeys !== undefined)
|
|
645
|
+
values.awsSelectedMetricKeys = updates.awsSelectedMetricKeys = data.awsSelectedMetricKeys;
|
|
646
|
+
if (data.awsDeploymentStatus !== undefined)
|
|
647
|
+
values.awsDeploymentStatus = updates.awsDeploymentStatus = data.awsDeploymentStatus;
|
|
648
|
+
if (data.awsDeploymentStatusReason !== undefined)
|
|
649
|
+
values.awsDeploymentStatusReason = updates.awsDeploymentStatusReason = data.awsDeploymentStatusReason;
|
|
650
|
+
if (data.awsStackId !== undefined)
|
|
651
|
+
values.awsStackId = updates.awsStackId = data.awsStackId;
|
|
652
|
+
if (!this.cloudWatchSetupTbl)
|
|
653
|
+
throw new Error("CloudWatch setup table is not configured");
|
|
654
|
+
await this.db
|
|
655
|
+
.insert(this.cloudWatchSetupTbl)
|
|
656
|
+
.values(values)
|
|
657
|
+
.onConflictDoUpdate({
|
|
658
|
+
target: this.cloudWatchSetupTbl.sourceId,
|
|
659
|
+
set: updates,
|
|
660
|
+
});
|
|
661
|
+
return this.findById(id, tenantId);
|
|
662
|
+
}
|
|
663
|
+
async updateCloudWatchDeployment(id, data, tenantId) {
|
|
664
|
+
const values = {
|
|
665
|
+
sourceId: id,
|
|
666
|
+
awsDeploymentStatus: data.awsDeploymentStatus,
|
|
667
|
+
};
|
|
668
|
+
const updates = {
|
|
669
|
+
updatedAt: new Date(),
|
|
670
|
+
awsDeploymentStatus: data.awsDeploymentStatus,
|
|
671
|
+
};
|
|
672
|
+
if (data.awsDeploymentStatusReason !== undefined)
|
|
673
|
+
values.awsDeploymentStatusReason = updates.awsDeploymentStatusReason = data.awsDeploymentStatusReason;
|
|
674
|
+
if (data.awsStackId !== undefined)
|
|
675
|
+
values.awsStackId = updates.awsStackId = data.awsStackId;
|
|
676
|
+
if (data.awsStackName !== undefined)
|
|
677
|
+
values.awsStackName = updates.awsStackName = data.awsStackName;
|
|
678
|
+
if (!this.cloudWatchSetupTbl)
|
|
679
|
+
throw new Error("CloudWatch setup table is not configured");
|
|
680
|
+
await this.db
|
|
681
|
+
.insert(this.cloudWatchSetupTbl)
|
|
682
|
+
.values(values)
|
|
683
|
+
.onConflictDoUpdate({
|
|
684
|
+
target: this.cloudWatchSetupTbl.sourceId,
|
|
685
|
+
set: updates,
|
|
686
|
+
});
|
|
687
|
+
return this.findById(id);
|
|
688
|
+
}
|
|
689
|
+
async updateGrafanaSetup(id, data, tenantId) {
|
|
690
|
+
if (!this.grafanaSetupTbl)
|
|
691
|
+
throw new Error("Grafana setup table is not configured");
|
|
692
|
+
const values = { sourceId: id };
|
|
693
|
+
const updates = { updatedAt: new Date() };
|
|
694
|
+
for (const [key, value] of Object.entries(data)) {
|
|
695
|
+
if (value !== undefined) {
|
|
696
|
+
values[key] = value;
|
|
697
|
+
updates[key] = value;
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
await this.db
|
|
701
|
+
.insert(this.grafanaSetupTbl)
|
|
702
|
+
.values(values)
|
|
703
|
+
.onConflictDoUpdate({
|
|
704
|
+
target: this.grafanaSetupTbl.sourceId,
|
|
705
|
+
set: updates,
|
|
706
|
+
});
|
|
707
|
+
return this.findById(id);
|
|
708
|
+
}
|
|
709
|
+
async updatePrometheusSetup(id, data, tenantId) {
|
|
710
|
+
if (!this.prometheusSetupTbl)
|
|
711
|
+
throw new Error("Prometheus setup table is not configured");
|
|
712
|
+
const values = { sourceId: id };
|
|
713
|
+
const updates = { updatedAt: new Date() };
|
|
714
|
+
for (const [key, value] of Object.entries(data)) {
|
|
715
|
+
if (value !== undefined) {
|
|
716
|
+
values[key] = value;
|
|
717
|
+
updates[key] = value;
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
await this.db
|
|
721
|
+
.insert(this.prometheusSetupTbl)
|
|
722
|
+
.values(values)
|
|
723
|
+
.onConflictDoUpdate({
|
|
724
|
+
target: this.prometheusSetupTbl.sourceId,
|
|
725
|
+
set: updates,
|
|
726
|
+
});
|
|
727
|
+
return this.findById(id);
|
|
728
|
+
}
|
|
729
|
+
async updateCloudTrailSetup(id, data, tenantId) {
|
|
730
|
+
if (!this.cloudTrailSetupTbl)
|
|
731
|
+
throw new Error("CloudTrail setup table is not configured");
|
|
732
|
+
const values = { sourceId: id };
|
|
733
|
+
const updates = { updatedAt: new Date() };
|
|
734
|
+
for (const [key, value] of Object.entries(data)) {
|
|
735
|
+
if (value !== undefined) {
|
|
736
|
+
values[key] = value;
|
|
737
|
+
updates[key] = value;
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
await this.db
|
|
741
|
+
.insert(this.cloudTrailSetupTbl)
|
|
742
|
+
.values(values)
|
|
743
|
+
.onConflictDoUpdate({
|
|
744
|
+
target: this.cloudTrailSetupTbl.sourceId,
|
|
745
|
+
set: updates,
|
|
746
|
+
});
|
|
747
|
+
return this.findById(id);
|
|
748
|
+
}
|
|
749
|
+
async updateCloudTrailDeployment(id, data, tenantId) {
|
|
750
|
+
const values = {
|
|
751
|
+
sourceId: id,
|
|
752
|
+
awsDeploymentStatus: data.awsDeploymentStatus,
|
|
753
|
+
};
|
|
754
|
+
const updates = {
|
|
755
|
+
updatedAt: new Date(),
|
|
756
|
+
awsDeploymentStatus: data.awsDeploymentStatus,
|
|
757
|
+
};
|
|
758
|
+
if (data.awsDeploymentStatusReason !== undefined)
|
|
759
|
+
values.awsDeploymentStatusReason = updates.awsDeploymentStatusReason = data.awsDeploymentStatusReason;
|
|
760
|
+
if (data.awsStackId !== undefined)
|
|
761
|
+
values.awsStackId = updates.awsStackId = data.awsStackId;
|
|
762
|
+
if (data.awsStackName !== undefined)
|
|
763
|
+
values.awsStackName = updates.awsStackName = data.awsStackName;
|
|
764
|
+
if (!this.cloudTrailSetupTbl)
|
|
765
|
+
throw new Error("CloudTrail setup table is not configured");
|
|
766
|
+
await this.db
|
|
767
|
+
.insert(this.cloudTrailSetupTbl)
|
|
768
|
+
.values(values)
|
|
769
|
+
.onConflictDoUpdate({
|
|
770
|
+
target: this.cloudTrailSetupTbl.sourceId,
|
|
771
|
+
set: updates,
|
|
772
|
+
});
|
|
773
|
+
return this.findById(id);
|
|
774
|
+
}
|
|
775
|
+
async delete(id, tenantId) {
|
|
776
|
+
if (this.cloudWatchSetupTbl) {
|
|
777
|
+
await this.db.delete(this.cloudWatchSetupTbl).where(eq(this.cloudWatchSetupTbl.sourceId, id));
|
|
778
|
+
}
|
|
779
|
+
if (this.grafanaSetupTbl) {
|
|
780
|
+
await this.db.delete(this.grafanaSetupTbl).where(eq(this.grafanaSetupTbl.sourceId, id));
|
|
781
|
+
}
|
|
782
|
+
if (this.prometheusSetupTbl) {
|
|
783
|
+
await this.db.delete(this.prometheusSetupTbl).where(eq(this.prometheusSetupTbl.sourceId, id));
|
|
784
|
+
}
|
|
785
|
+
if (this.cloudTrailSetupTbl) {
|
|
786
|
+
await this.db.delete(this.cloudTrailSetupTbl).where(eq(this.cloudTrailSetupTbl.sourceId, id));
|
|
787
|
+
}
|
|
788
|
+
const conditions = [eq(this.tbl.id, id)];
|
|
789
|
+
if (tenantId)
|
|
790
|
+
conditions.push(eq(this.tbl.tenantId, tenantId));
|
|
791
|
+
await this.db.delete(this.tbl).where(and(...conditions));
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
//# sourceMappingURL=source.model.js.map
|