Skip to content

Commit

Permalink
chore: prune unused types
Browse files Browse the repository at this point in the history
  • Loading branch information
eoinsha committed Nov 14, 2023
1 parent cb2bad5 commit 8038cc2
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 44 deletions.
5 changes: 0 additions & 5 deletions core/alarms/alarm-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ export interface SlicWatchMergedConfig extends AlarmProperties {

export type InputOutput = SlicWatchAlarmConfig | SlicWatchMergedConfig

export interface ReturnAlarm {
resourceName: string
resource: Resource
}

export interface AlarmActionsConfig {
actionsEnabled?: boolean
okActions?: string[]
Expand Down
2 changes: 0 additions & 2 deletions core/alarms/lambda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ export interface SlicWatchLambdaAlarmsConfig<T extends InputOutput> extends Slic
IteratorAge: T
}

export type FunctionAlarmProperties<T extends InputOutput> = Record<string, SlicWatchLambdaAlarmsConfig<T>>

const lambdaMetrics = ['Errors', 'ThrottlesPc', 'DurationPc', 'Invocations']

/**
Expand Down
17 changes: 0 additions & 17 deletions core/dashboards/dashboard-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,6 @@ export interface WidgetWithSize extends Omit<Widget, 'width' | 'height'> {
height: number
}

export interface MetricProperties {
metrics: any[][]
title: string
view: string
region: string
period?: number
yAxis?: YAxisPos
}

export interface CreateMetricWidget {
type: string
properties: MetricProperties
width: number
height: number
yAxis?: YAxisPos
}

export interface WidgetMetricProperties {
enabled: boolean
metricPeriod: number
Expand Down
23 changes: 13 additions & 10 deletions core/dashboards/dashboard.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import type Template from 'cloudform-types/types/template'
import * as cwd from 'cloudwatch-dashboard-types'
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
import type {
Dashboard, WidgetMetric, Statistic, YAxisPosition, WidgetType, MetricViewType
} from 'cloudwatch-dashboard-types'

import { cascade } from '../inputs/cascading-config'
import { getResourcesByType, getEventSourceMappingFunctions, addResource } from '../cf-template'
Expand Down Expand Up @@ -94,7 +97,7 @@ export default function addDashboard (dashboardConfig: SlicWatchInputDashboardCo
])

if (positionedWidgets.length > 0) {
const dash: cwd.Dashboard = { start: timeRange?.start, end: timeRange?.end, widgets: positionedWidgets }
const dash: Dashboard = { start: timeRange?.start, end: timeRange?.end, widgets: positionedWidgets }
const dashboardResource = {
Type: 'AWS::CloudWatch::Dashboard',
Properties: {
Expand All @@ -115,23 +118,23 @@ export default function addDashboard (dashboardConfig: SlicWatchInputDashboardCo
* @param {Object} config Cascaded widget/metric configuration
*/
function createMetricWidget (title: string, metricDefs: MetricDefs[], config: WidgetMetricProperties): WidgetWithSize {
const metrics: cwd.WidgetMetric[] = metricDefs.map(
const metrics: WidgetMetric[] = metricDefs.map(
({ namespace, metric, dimensions, stat, yAxis }) => [
namespace,
metric,
...Object.entries(dimensions).reduce(
(acc: string[], [name, value]) => [...acc, name, value],
[]
),
{ stat: stat as cwd.Statistic, yAxis: yAxis as cwd.YAxisPosition }
{ stat: stat as Statistic, yAxis: yAxis as YAxisPosition }
]
)
return {
type: cwd.WidgetType.Metric,
type: WidgetType.Metric,
properties: {
metrics,
title,
view: cwd.MetricViewType.TimeSeries,
view: MetricViewType.TimeSeries,
region: '${AWS::Region}',
period: config.metricPeriod
},
Expand Down Expand Up @@ -170,7 +173,7 @@ export default function addDashboard (dashboardConfig: SlicWatchInputDashboardCo
namespace: 'AWS/Lambda',
metric,
dimensions: { FunctionName: `\${${funcLogicalId}}` },
stat: stat as cwd.Statistic
stat: stat as Statistic
})
}
}
Expand Down Expand Up @@ -198,7 +201,7 @@ export default function addDashboard (dashboardConfig: SlicWatchInputDashboardCo
namespace: 'AWS/Lambda',
metric: 'IteratorAge',
dimensions: { FunctionName: `\${${funcLogicalId}}` },
stat: stat as cwd.Statistic
stat: stat as Statistic
})),
metricConfig as Widgets
)
Expand Down Expand Up @@ -660,8 +663,8 @@ export default function addDashboard (dashboardConfig: SlicWatchInputDashboardCo
namespace: 'AWS/AppSync',
metric,
dimensions: { GraphQLAPIId: graphQLAPIId },
stat: stat as cwd.Statistic,
yAxis: metricConfig.yAxis as cwd.YAxisPosition
stat: stat as Statistic,
yAxis: metricConfig.yAxis as YAxisPosition
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"yaml": "^1.10.2"
},
"devDependencies": {
"cloudwatch-dashboard-types": "^1.0.0-rc1",
"cloudwatch-dashboard-types": "^1.0.1-rc2",
"ts-node": "^10.9.1"
}
}
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"resolveJsonModule": true,
"target": "ESNext",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true
"esModuleInterop": true,
},
"ts-node": {
"swc": true,
Expand Down

0 comments on commit 8038cc2

Please sign in to comment.