diff --git a/server/src/models/analytic_unit_cache_model.ts b/server/src/models/analytic_unit_cache_model.ts index 9bef173..80de419 100644 --- a/server/src/models/analytic_unit_cache_model.ts +++ b/server/src/models/analytic_unit_cache_model.ts @@ -82,7 +82,6 @@ export async function create(id: AnalyticUnitId): Promise { return db.insertOne(cache.toObject()); } -// TODO: SerializedCache type export async function insertMany(caches: any[]): Promise { return db.insertMany(caches); } diff --git a/server/src/models/analytic_units/analytic_unit_model.ts b/server/src/models/analytic_units/analytic_unit_model.ts index 1b9d715..84759e6 100644 --- a/server/src/models/analytic_units/analytic_unit_model.ts +++ b/server/src/models/analytic_units/analytic_unit_model.ts @@ -1,6 +1,5 @@ import { - AnalyticUnitId, AnalyticUnitStatus, DetectorType, - SerializedAnalyticUnit, SerializedPanelAnalyticUnit + AnalyticUnitId, AnalyticUnitStatus, DetectorType } from './types'; import { Metric } from 'grafana-datasource-kit'; @@ -43,7 +42,7 @@ export abstract class AnalyticUnit { } } - public toObject(): SerializedAnalyticUnit { + public toObject(): any { let metric; if(this.metric !== undefined) { metric = this.metric.toObject(); @@ -68,7 +67,7 @@ export abstract class AnalyticUnit { }; } - public toPanelObject(): SerializedPanelAnalyticUnit { + public toPanelObject(): any { return { id: this.id, name: this.name, @@ -82,7 +81,7 @@ export abstract class AnalyticUnit { }; } - public toTemplate(): SerializedAnalyticUnit { + public toTemplate(): any { const obj = _.cloneDeep(this.toObject()); obj.grafanaUrl = '${GRAFANA_URL}'; diff --git a/server/src/models/analytic_units/db.ts b/server/src/models/analytic_units/db.ts index c588fda..2ec603b 100644 --- a/server/src/models/analytic_units/db.ts +++ b/server/src/models/analytic_units/db.ts @@ -1,6 +1,6 @@ import { createAnalyticUnitFromObject } from './utils'; import { AnalyticUnit } from './analytic_unit_model'; -import { AnalyticUnitId, FindManyQuery, SerializedAnalyticUnit } from './types'; +import { AnalyticUnitId, FindManyQuery } from './types'; import { Collection, makeDBQ, SortingOrder } from '../../services/data_service'; import { Metric } from 'grafana-datasource-kit'; @@ -41,7 +41,7 @@ export async function create(unit: AnalyticUnit): Promise { return db.insertOne(obj); } -export async function insertMany(analyticUnits: SerializedAnalyticUnit[]): Promise { +export async function insertMany(analyticUnits: any[]): Promise { return db.insertMany(analyticUnits); } diff --git a/server/src/models/analytic_units/index.ts b/server/src/models/analytic_units/index.ts index 2b73da0..4cc3682 100644 --- a/server/src/models/analytic_units/index.ts +++ b/server/src/models/analytic_units/index.ts @@ -1,7 +1,6 @@ import { createAnalyticUnitFromObject } from './utils'; import { - AnalyticUnitId, AnalyticUnitStatus, DetectorType, ANALYTIC_UNIT_TYPES, - SerializedAnalyticUnit, SerializedPanelAnalyticUnit + AnalyticUnitId, AnalyticUnitStatus, DetectorType, ANALYTIC_UNIT_TYPES } from './types'; import { AnalyticUnit } from './analytic_unit_model'; import { PatternAnalyticUnit } from './pattern_analytic_unit_model'; @@ -23,7 +22,6 @@ import { export { AnalyticUnit, PatternAnalyticUnit, ThresholdAnalyticUnit, AnomalyAnalyticUnit, - SerializedAnalyticUnit, SerializedPanelAnalyticUnit, AnalyticUnitId, AnalyticUnitStatus, Bound, DetectorType, ANALYTIC_UNIT_TYPES, createAnalyticUnitFromObject, Condition, findById, findMany, diff --git a/server/src/models/analytic_units/types.ts b/server/src/models/analytic_units/types.ts index 2d6b040..e95eaa9 100644 --- a/server/src/models/analytic_units/types.ts +++ b/server/src/models/analytic_units/types.ts @@ -1,5 +1,3 @@ -import { Omit } from '../../types'; - import { Metric } from 'grafana-datasource-kit'; @@ -73,25 +71,3 @@ export enum DetectorType { ANOMALY = 'anomaly', THRESHOLD = 'threshold' }; - -export type SerializedPanelAnalyticUnit = { - id: AnalyticUnitId; - name: string; - type: string; - alert: boolean; - labeledColor?: string; - deletedColor?: string; - detectorType?: DetectorType; - visible?: boolean; - collapsed?: boolean; -} - -export type SerializedAnalyticUnit = Omit & { - grafanaUrl: string; - panelId: string; - metric?: Metric; - _id?: AnalyticUnitId; - lastDetectionTime?: number; - status?: AnalyticUnitStatus; - error?: string; -} diff --git a/server/src/models/detection_model.ts b/server/src/models/detection_model.ts index 5b4e76f..afca0cc 100644 --- a/server/src/models/detection_model.ts +++ b/server/src/models/detection_model.ts @@ -162,7 +162,6 @@ export async function insertSpan(span: DetectionSpan): Promise { return db.insertOne(spanToInsert); } -// TODO: SerializedDetectionSpan type export async function insertMany(detectionSpans: any[]): Promise { return db.insertMany(detectionSpans); } diff --git a/server/src/models/panel_model.ts b/server/src/models/panel_model.ts index 3317256..0869b21 100644 --- a/server/src/models/panel_model.ts +++ b/server/src/models/panel_model.ts @@ -4,7 +4,7 @@ import * as DetectionSpan from '../models/detection_model'; import * as Segment from '../models/segment_model'; export type PanelTemplate = { - analyticUnits: AnalyticUnit.SerializedAnalyticUnit[], + analyticUnits: AnalyticUnit.AnalyticUnit[], caches: AnalyticUnitCache.AnalyticUnitCache[], detectionSpans: DetectionSpan.DetectionSpan[], segments: Segment.Segment[] diff --git a/server/src/models/segment_model.ts b/server/src/models/segment_model.ts index 15e4b96..992a218 100644 --- a/server/src/models/segment_model.ts +++ b/server/src/models/segment_model.ts @@ -232,7 +232,6 @@ export async function mergeAndInsertSegments(segments: Segment[]): Promise<{ }; } -// TODO: SerializedSegment type export async function insertMany(segments: any[]): Promise { return db.insertMany(segments); } diff --git a/server/src/types.ts b/server/src/types.ts deleted file mode 100644 index 848c2cc..0000000 --- a/server/src/types.ts +++ /dev/null @@ -1,7 +0,0 @@ -// We should remove Omit definition when we'll be updating TypeScript -// It was introduced in TS v3.5.1: -// https://devblogs.microsoft.com/typescript/announcing-typescript-3-5/#the-omit-helper-type -/** - * Construct a type with the properties of T except for those in type K. -*/ -export type Omit = { [P in Exclude]: T[P]; }