Skip to content

Commit

Permalink
chore: simplify typings
Browse files Browse the repository at this point in the history
  • Loading branch information
RomRider committed Feb 23, 2021
1 parent ef81f13 commit c097431
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 93 deletions.
40 changes: 20 additions & 20 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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"parse-duration": "^0.4.4",
"spark-md5": "^3.0.1",
"tinycolor": "^0.0.1",
"ts-interface-checker": "^0.1.13"
"ts-interface-checker": "^0.2.0"
},
"devDependencies": {
"@babel/core": "^7.12.10",
Expand Down
36 changes: 2 additions & 34 deletions src/types-config-ti.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const ChartCardSpanExtConfig = t.iface([], {
});

export const ChartCardAllSeriesExternalConfig = t.iface([], {
"entity": t.opt("string"),
"attribute": t.opt("string"),
"name": t.opt("string"),
"type": t.opt(t.union(t.lit('line'), t.lit('column'), t.lit('area'))),
Expand Down Expand Up @@ -80,41 +81,8 @@ export const ChartCardAllSeriesExternalConfig = t.iface([], {
"color_threshold": t.opt(t.array("ChartCardColorThreshold")),
});

export const ChartCardSeriesExternalConfig = t.iface([], {
export const ChartCardSeriesExternalConfig = t.iface(["ChartCardAllSeriesExternalConfig"], {
"entity": "string",
"attribute": t.opt("string"),
"name": t.opt("string"),
"type": t.opt(t.union(t.lit('line'), t.lit('column'), t.lit('area'))),
"color": t.opt("string"),
"opacity": t.opt("number"),
"curve": t.opt(t.union(t.lit('smooth'), t.lit('straight'), t.lit('stepline'))),
"stroke_width": t.opt("number"),
"extend_to_end": t.opt("boolean"),
"unit": t.opt("string"),
"invert": t.opt("boolean"),
"data_generator": t.opt("string"),
"float_precision": t.opt("number"),
"min": t.opt("number"),
"max": t.opt("number"),
"offset": t.opt("string"),
"fill_raw": t.opt("GroupByFill"),
"show": t.opt(t.iface([], {
"as_duration": t.opt("ChartCardPrettyTime"),
"legend_value": t.opt("boolean"),
"in_header": t.opt(t.union("boolean", t.lit('raw'))),
"header_color_threshold": t.opt("boolean"),
"in_chart": t.opt("boolean"),
"datalabels": t.opt(t.union("boolean", t.lit('total'))),
"hidden_by_default": t.opt("boolean"),
"extremas": t.opt(t.union("boolean", t.lit('time'))),
})),
"group_by": t.opt(t.iface([], {
"duration": t.opt("string"),
"func": t.opt("GroupByFunc"),
"fill": t.opt("GroupByFill"),
})),
"transform": t.opt("string"),
"color_threshold": t.opt(t.array("ChartCardColorThreshold")),
});

export const ChartCardPrettyTime = t.union(t.lit('millisecond'), t.lit('second'), t.lit('minute'), t.lit('hour'), t.lit('day'), t.lit('week'), t.lit('month'), t.lit('year'));
Expand Down
40 changes: 2 additions & 38 deletions src/types-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export interface ChartCardSpanExtConfig {
}

export interface ChartCardAllSeriesExternalConfig {
entity?: string;
attribute?: string;
name?: string;
type?: 'line' | 'column' | 'area';
Expand Down Expand Up @@ -77,45 +78,8 @@ export interface ChartCardAllSeriesExternalConfig {
color_threshold?: ChartCardColorThreshold[];
}

// Need to duplicate because of https://github.com/gristlabs/ts-interface-checker/issues/35
// export interface ChartCardSeriesExternalConfig extends ChartCardAllSeriesExternalConfig {
// entity: string;
// }
export interface ChartCardSeriesExternalConfig {
export interface ChartCardSeriesExternalConfig extends ChartCardAllSeriesExternalConfig {
entity: string;
attribute?: string;
name?: string;
type?: 'line' | 'column' | 'area';
color?: string;
opacity?: number;
curve?: 'smooth' | 'straight' | 'stepline';
stroke_width?: number;
extend_to_end?: boolean;
unit?: string;
invert?: boolean;
data_generator?: string;
float_precision?: number;
min?: number;
max?: number;
offset?: string;
fill_raw?: GroupByFill;
show?: {
as_duration?: ChartCardPrettyTime;
legend_value?: boolean;
in_header?: boolean | 'raw';
header_color_threshold?: boolean;
in_chart?: boolean;
datalabels?: boolean | 'total';
hidden_by_default?: boolean;
extremas?: boolean | 'time';
};
group_by?: {
duration?: string;
func?: GroupByFunc;
fill?: GroupByFill;
};
transform?: string;
color_threshold?: ChartCardColorThreshold[];
}

export type ChartCardPrettyTime = 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';
Expand Down

0 comments on commit c097431

Please sign in to comment.