chore: synchronize pending app/backend updates and repository hygiene
Includes current frontend and backend work in progress and removes generated artifacts from tracking to keep the repository clean for дальнейшая разработка. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -115,6 +115,46 @@ export const trafficSettings = sqliteTable("traffic_settings", {
|
||||
updatedAt: text("updated_at").notNull().default(sql`(datetime('now'))`),
|
||||
})
|
||||
|
||||
/** Настройки фоновой проверки доступности RouterOS REST API по серверам каталога. */
|
||||
export const serversApiPingSettings = sqliteTable("servers_api_ping_settings", {
|
||||
id: integer("id").primaryKey(),
|
||||
enabled: integer("enabled", { mode: "boolean" }).notNull().default(false),
|
||||
intervalSec: integer("interval_sec").notNull().default(120),
|
||||
lastCollectedAt: text("last_collected_at"),
|
||||
lastDurationMs: integer("last_duration_ms"),
|
||||
lastError: text("last_error"),
|
||||
createdAt: text("created_at").notNull().default(sql`(datetime('now'))`),
|
||||
updatedAt: text("updated_at").notNull().default(sql`(datetime('now'))`),
|
||||
})
|
||||
|
||||
/** Сырые пробы REST `/system/identity` по серверам — для UI сбора и для `buildSignalSnapshot` (алерты). */
|
||||
export const serversRestPingSamples = sqliteTable("servers_rest_ping_samples", {
|
||||
id: integer("id").primaryKey({ autoIncrement: true }),
|
||||
serverId: integer("server_id")
|
||||
.notNull()
|
||||
.references(() => servers.id, { onDelete: "cascade" }),
|
||||
sampledAt: text("sampled_at").notNull(),
|
||||
ok: integer("ok", { mode: "boolean" }).notNull(),
|
||||
latencyMs: integer("latency_ms"),
|
||||
error: text("error"),
|
||||
})
|
||||
|
||||
/** Сырые снимки GRE для алертов — пишет джоба `gre_bgp`. */
|
||||
export const alertGreTunnelSamples = sqliteTable("alert_gre_tunnel_samples", {
|
||||
id: integer("id").primaryKey({ autoIncrement: true }),
|
||||
sampledAt: text("sampled_at").notNull(),
|
||||
targetLabel: text("target_label").notNull(),
|
||||
status: text("status").notNull(),
|
||||
})
|
||||
|
||||
/** Сырые снимки BGP-сессий для алертов — пишет джоба `gre_bgp`. */
|
||||
export const alertBgpPeerSamples = sqliteTable("alert_bgp_peer_samples", {
|
||||
id: integer("id").primaryKey({ autoIncrement: true }),
|
||||
sampledAt: text("sampled_at").notNull(),
|
||||
peerKey: text("peer_key").notNull(),
|
||||
state: text("state").notNull(),
|
||||
})
|
||||
|
||||
// ── raw traffic samples (per server/interface/timepoint) ──────────────────────
|
||||
|
||||
export const trafficSamples = sqliteTable("traffic_samples", {
|
||||
@@ -136,7 +176,11 @@ export const trafficSamples = sqliteTable("traffic_samples", {
|
||||
|
||||
export const uptimeSettings = sqliteTable("uptime_settings", {
|
||||
id: integer("id").primaryKey(),
|
||||
/** Устаревший агрегат: синхронизируется как resources ∨ ping ∨ speed (для совместимости). */
|
||||
enabled: integer("enabled", { mode: "boolean" }).notNull().default(true),
|
||||
resourcesEnabled: integer("resources_enabled", { mode: "boolean" }).notNull().default(true),
|
||||
pingEnabled: integer("ping_enabled", { mode: "boolean" }).notNull().default(true),
|
||||
speedEnabled: integer("speed_enabled", { mode: "boolean" }).notNull().default(true),
|
||||
intervalSec: integer("interval_sec").notNull().default(15),
|
||||
probeIntervalSec: integer("probe_interval_sec").notNull().default(15),
|
||||
speedIntervalSec: integer("speed_interval_sec").notNull().default(60),
|
||||
@@ -158,6 +202,8 @@ export const uptimeProbes = sqliteTable("uptime_probes", {
|
||||
target: text("target").notNull(),
|
||||
probeFilter: text("probe_filter").notNull().default("—"),
|
||||
enabled: integer("enabled", { mode: "boolean" }).notNull().default(true),
|
||||
/** 0 — брать глобальный probe_interval_sec из uptime_settings */
|
||||
intervalSec: integer("interval_sec").notNull().default(0),
|
||||
/** Выводить пробу в блоке «Активные пробы» на дашборде */
|
||||
showOnDashboard: integer("show_on_dashboard", { mode: "boolean" }).notNull().default(false),
|
||||
sortOrder: integer("sort_order").notNull().default(0),
|
||||
@@ -231,6 +277,155 @@ export const evobgpSettings = sqliteTable("evobgp_settings", {
|
||||
updatedAt: text("updated_at").notNull().default(sql`(datetime('now'))`),
|
||||
})
|
||||
|
||||
/** Единственная строка id=1: токен и чат Telegram для оповещений. */
|
||||
export const alertTelegramSettings = sqliteTable("alert_telegram_settings", {
|
||||
id: integer("id").primaryKey(),
|
||||
botToken: text("bot_token").notNull().default(""),
|
||||
chatId: text("chat_id").notNull().default(""),
|
||||
/** Тема супергруппы (forum): `message_thread_id` в Bot API; NULL — общий чат */
|
||||
messageThreadId: integer("message_thread_id"),
|
||||
updatedAt: text("updated_at").notNull().default(sql`(datetime('now'))`),
|
||||
})
|
||||
|
||||
/** Группы правил: ANY = хотя бы одно; ALL = все одновременно в окне тика. */
|
||||
export const alertGroups = sqliteTable("alert_groups", {
|
||||
id: text("id").primaryKey(),
|
||||
name: text("name").notNull(),
|
||||
combineMode: text("combine_mode", { enum: ["any", "all"] }).notNull().default("any"),
|
||||
enabled: integer("enabled", { mode: "boolean" }).notNull().default(true),
|
||||
/** Переопределение cooldown для агрегата группы; NULL — по умолчанию 5м */
|
||||
cooldownOverride: text("cooldown_override", {
|
||||
enum: ["1м", "5м", "15м", "1ч", "4ч", "24ч"],
|
||||
}),
|
||||
createdAt: text("created_at").notNull().default(sql`(datetime('now'))`),
|
||||
updatedAt: text("updated_at").notNull().default(sql`(datetime('now'))`),
|
||||
})
|
||||
|
||||
/** Правила оповещений (UI /alerts). */
|
||||
export const alertRules = sqliteTable("alert_rules", {
|
||||
id: text("id").primaryKey(),
|
||||
name: text("name").notNull(),
|
||||
type: text("type", {
|
||||
enum: ["gre-tunnel", "bgp-peer", "bgp-prefix", "gre-client", "server", "rtt", "loss", "traffic"],
|
||||
}).notNull(),
|
||||
/** Сводная подпись (первый target или join); для совместимости и поиска */
|
||||
target: text("target").notNull(),
|
||||
condition: text("condition").notNull(),
|
||||
severity: text("severity", { enum: ["critical", "warning", "info"] }).notNull(),
|
||||
enabled: integer("enabled", { mode: "boolean" }).notNull().default(true),
|
||||
cooldown: text("cooldown", {
|
||||
enum: ["1м", "5м", "15м", "1ч", "4ч", "24ч"],
|
||||
}).notNull().default("5м"),
|
||||
chatId: text("rule_chat_id").notNull().default(""),
|
||||
/** NULL / 0 — выкл. Секунды: уведомление только если условие держится столько времени без «отмены» (восстановление сигнала). */
|
||||
confirmStabilitySec: integer("confirm_stability_sec"),
|
||||
/** Политика recovery-уведомления для правила. */
|
||||
recoveryMode: text("recovery_mode", {
|
||||
enum: ["always", "never", "conditional"],
|
||||
}).notNull().default("always"),
|
||||
/** Доп. задержка подтверждения для recovery при `conditional`; NULL — без доп. ожидания. */
|
||||
recoveryStabilitySec: integer("recovery_stability_sec"),
|
||||
/** NULL — правило вне группы (отдельные отправки по cooldown правила) */
|
||||
groupId: text("group_id"),
|
||||
createdAt: text("created_at").notNull().default(sql`(datetime('now'))`),
|
||||
updatedAt: text("updated_at").notNull().default(sql`(datetime('now'))`),
|
||||
})
|
||||
|
||||
/** Несколько объектов на правило; срабатывание по OR (хотя бы один). */
|
||||
export const alertRuleTargets = sqliteTable("alert_rule_targets", {
|
||||
id: text("id").primaryKey(),
|
||||
ruleId: text("rule_id").notNull(),
|
||||
target: text("target").notNull(),
|
||||
sortIndex: integer("sort_index").notNull().default(0),
|
||||
})
|
||||
|
||||
/** Несколько условий на правило; срабатывание по OR (любое из выбранных). */
|
||||
export const alertRuleConditions = sqliteTable("alert_rule_conditions", {
|
||||
id: text("id").primaryKey(),
|
||||
ruleId: text("rule_id").notNull(),
|
||||
conditionLine: text("condition_line").notNull(),
|
||||
sortIndex: integer("sort_index").notNull().default(0),
|
||||
})
|
||||
|
||||
/** Состояние движка: cooldown / дедуп по ключу rule:id или group:id */
|
||||
export const alertEngineState = sqliteTable("alert_engine_state", {
|
||||
scopeKey: text("scope_key").primaryKey(),
|
||||
lastFiredAt: text("last_fired_at").notNull().default(""),
|
||||
lastPayloadHash: text("last_payload_hash"),
|
||||
})
|
||||
|
||||
/** Снимок прошлого тика для live-сигналов (GRE/BGP): переходы «offline» / «восстановился». */
|
||||
export const alertEnginePrevLive = sqliteTable("alert_engine_prev_live", {
|
||||
kind: text("kind", { enum: ["gre", "bgp"] }).primaryKey(),
|
||||
payloadJson: text("payload_json").notNull().default("{}"),
|
||||
updatedAt: text("updated_at").notNull().default(sql`(datetime('now'))`),
|
||||
})
|
||||
|
||||
/** Ожидание стабильности срабатывания по правилу (антидребезг). */
|
||||
export const alertEngineConfirmPending = sqliteTable("alert_engine_confirm_pending", {
|
||||
ruleId: text("rule_id").primaryKey(),
|
||||
payloadHash: text("payload_hash").notNull(),
|
||||
sinceAt: text("since_at").notNull(),
|
||||
})
|
||||
|
||||
/** Задел: несколько получателей Telegram (пока UI не подключён) */
|
||||
export const alertDestinations = sqliteTable("alert_destinations", {
|
||||
id: text("id").primaryKey(),
|
||||
kind: text("kind", { enum: ["telegram"] }).notNull().default("telegram"),
|
||||
label: text("label").notNull().default(""),
|
||||
telegramChatId: text("telegram_chat_id").notNull().default(""),
|
||||
messageThreadId: integer("message_thread_id"),
|
||||
enabled: integer("enabled", { mode: "boolean" }).notNull().default(true),
|
||||
createdAt: text("created_at").notNull().default(sql`(datetime('now'))`),
|
||||
})
|
||||
|
||||
/** Журнал отправок / срабатываний (персист + при необходимости пополняется воркером). */
|
||||
export const alertHistory = sqliteTable("alert_history", {
|
||||
id: text("id").primaryKey(),
|
||||
ruleId: text("rule_id"),
|
||||
groupId: text("group_id"),
|
||||
ruleName: text("rule_name").notNull(),
|
||||
severity: text("severity", { enum: ["critical", "warning", "info"] }).notNull(),
|
||||
message: text("message").notNull(),
|
||||
sentOk: integer("sent_ok", { mode: "boolean" }).notNull().default(true),
|
||||
firedAt: text("fired_at").notNull(),
|
||||
})
|
||||
|
||||
/** Outbox доставки уведомлений: ретраи и идемпотентность отправки каналов. */
|
||||
export const alertOutbox = sqliteTable("alert_outbox", {
|
||||
id: text("id").primaryKey(),
|
||||
dedupeKey: text("dedupe_key").notNull(),
|
||||
channel: text("channel", { enum: ["telegram"] }).notNull().default("telegram"),
|
||||
status: text("status", { enum: ["pending", "sent", "failed"] }).notNull().default("pending"),
|
||||
retryCount: integer("retry_count").notNull().default(0),
|
||||
maxRetries: integer("max_retries").notNull().default(3),
|
||||
nextAttemptAt:text("next_attempt_at").notNull(),
|
||||
payloadJson: text("payload_json").notNull(),
|
||||
createdAt: text("created_at").notNull().default(sql`(datetime('now'))`),
|
||||
sentAt: text("sent_at"),
|
||||
lastError: text("last_error"),
|
||||
})
|
||||
|
||||
/** Cursor движка: watermark последней обработанной точки snapshot-источников. */
|
||||
export const alertEngineCursor = sqliteTable("alert_engine_cursor", {
|
||||
id: integer("id").primaryKey(),
|
||||
lastSourceFinishedAt: text("last_source_finished_at"),
|
||||
updatedAt: text("updated_at").notNull().default(sql`(datetime('now'))`),
|
||||
})
|
||||
|
||||
/** Журнал прогонов планировщика (аудит). */
|
||||
export const schedulerRuns = sqliteTable("scheduler_runs", {
|
||||
id: text("id").primaryKey(),
|
||||
jobKey: text("job_key").notNull(),
|
||||
startedAt: text("started_at").notNull(),
|
||||
finishedAt: text("finished_at").notNull(),
|
||||
status: text("status", { enum: ["ok", "error"] }).notNull(),
|
||||
error: text("error"),
|
||||
durationMs: integer("duration_ms").notNull().default(0),
|
||||
/** JSON: см. `SchedulerRunSnapshot` в types/scheduler-run-snapshot.ts */
|
||||
resultJson: text("result_json"),
|
||||
})
|
||||
|
||||
export const uptimeSpeedTestRuns = sqliteTable("uptime_speed_test_runs", {
|
||||
id: text("id").primaryKey(),
|
||||
probeId: text("probe_id"),
|
||||
@@ -264,6 +459,7 @@ export type SnapshotInsert = typeof serverSnapshots.$inferInsert
|
||||
export type FilterRuleRow = typeof filterRules.$inferSelect
|
||||
export type RecursiveRouteRow = typeof recursiveRoutes.$inferSelect
|
||||
export type TrafficSettingsRow = typeof trafficSettings.$inferSelect
|
||||
export type ServersApiPingSettingsRow = typeof serversApiPingSettings.$inferSelect
|
||||
export type TrafficSampleRow = typeof trafficSamples.$inferSelect
|
||||
export type UptimeSettingsRow = typeof uptimeSettings.$inferSelect
|
||||
export type UptimeProbeRow = typeof uptimeProbes.$inferSelect
|
||||
@@ -271,4 +467,14 @@ export type UptimeProbeSampleRow = typeof uptimeProbeSamples.$inferSelect
|
||||
export type UptimeResourceSampleRow = typeof uptimeResourceSamples.$inferSelect
|
||||
export type UptimeSpeedProbeRow = typeof uptimeSpeedProbes.$inferSelect
|
||||
export type UptimeSpeedTestRunRow = typeof uptimeSpeedTestRuns.$inferSelect
|
||||
export type SchedulerRunRow = typeof schedulerRuns.$inferSelect
|
||||
export type EvobgpSettingsRow = typeof evobgpSettings.$inferSelect
|
||||
export type AlertTelegramSettingsRow = typeof alertTelegramSettings.$inferSelect
|
||||
export type AlertGroupRow = typeof alertGroups.$inferSelect
|
||||
export type AlertRuleRow = typeof alertRules.$inferSelect
|
||||
export type AlertRuleTargetRow = typeof alertRuleTargets.$inferSelect
|
||||
export type AlertEngineStateRow = typeof alertEngineState.$inferSelect
|
||||
export type AlertDestinationRow = typeof alertDestinations.$inferSelect
|
||||
export type AlertHistoryRow = typeof alertHistory.$inferSelect
|
||||
export type AlertOutboxRow = typeof alertOutbox.$inferSelect
|
||||
export type AlertEngineCursorRow = typeof alertEngineCursor.$inferSelect
|
||||
|
||||
Reference in New Issue
Block a user