Skip to content

Commit

Permalink
fix(@cubejs-core): Add type definition for compareDateRange, fix #1621 (
Browse files Browse the repository at this point in the history
#1623). Thanks to @cbroome!

* fix(@cubejs-core): Add type definition for compareDateRange, fix #1621

* fix(@cubejs-core): make the type definitions a little less strict fix #1621

* fix(@cubejs-core): make the type definitions even a little less stricter fix #1621

* fix(@cubejs-core): use types instead of interfaces for TimeDimensions #1621

* fix(@cubejs-core): stricter enforcement for DateRange type in TimeDimensions #1621

Co-authored-by: Christopher Broome <cbroome@tradeswell.com>
  • Loading branch information
cbroome and cbroome committed Dec 17, 2020
1 parent b18690e commit d8b7f36
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions packages/cubejs-client-core/index.d.ts
Expand Up @@ -455,11 +455,11 @@ declare module '@cubejs-client/core' {
* { "x":"2015-03-01T00:00:00", "Stories.count": 29661, "xValues": ["2015-03-01T00:00:00"] },
* //...
* ]
*
*
* ```
* When using `chartPivot()` or `seriesNames()`, you can pass `aliasSeries` in the [pivotConfig](#types-pivot-config)
* to give each series a unique prefix. This is useful for `blending queries` which use the same measure multiple times.
*
*
* ```js
* // For the queries
* {
Expand Down Expand Up @@ -489,7 +489,7 @@ declare module '@cubejs-client/core' {
* },
* ],
* },
*
*
* // ResultSet.chartPivot({ aliasSeries: ['one', 'two'] }) will return
* [
* {
Expand Down Expand Up @@ -680,12 +680,24 @@ declare module '@cubejs-client/core' {

export type TimeDimensionGranularity = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';

export type TimeDimension = {
export type DateRange = string | [string, string];

export type TimeDimensionBase = {
dimension: string;
dateRange?: string | string[];
granularity?: TimeDimensionGranularity;
};

export type TimeDimensionComparison = TimeDimensionBase & {
compareDateRange: Array<DateRange>;
dateRange?: never;
};

export type TimeDimensionRanged = TimeDimensionBase & {
dateRange?: DateRange;
};

export type TimeDimension = TimeDimensionComparison | TimeDimensionRanged;

export type Query = {
measures?: string[];
dimensions?: string[];
Expand Down

0 comments on commit d8b7f36

Please sign in to comment.