From 33723f4ea2ead9cbd3ac327aa661f0b7f7470279 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Mon, 23 Sep 2024 15:13:45 -0600 Subject: [PATCH] Improve TimeInterval type --- src/index.tsx | 19 +++++++++++-------- src/schema.gql | 26 +++++++++++--------------- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index b460920..f2c34a9 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -72,6 +72,12 @@ export type AggregationInput = } | { bucketSet?: never; datetimeRange?: never; enum: EnumAggregation }; +export enum AlignedIntervalEnum { + Month = "MONTH", + Week = "WEEK", + Year = "YEAR", +} + export type BankFeaturesGql = { __typename?: "BankFeaturesGQL"; bankAngle: Scalars["Float"]["output"]; @@ -1914,20 +1920,17 @@ export type TargetMetricsGql = { spinTypeCounts?: Maybe; }; -export type TimeInterval = { - /** True eg 1/15-3/15 => [(1/15,1/31), (2/1,2/28), (3/1,3/15)] False eg 1/15-2/15 => [(1/15,2/14), (2/14,3/15)] */ - calendarAlignedMonths?: Scalars["Boolean"]["input"]; +export type TimeDeltaGql = { days?: InputMaybe; - hours?: InputMaybe; - minutes?: InputMaybe; months?: InputMaybe; - /** A second is the base unit and cannot be subdivided */ - seconds?: InputMaybe; weeks?: InputMaybe; - /** Assumes a year is 365 days long */ years?: InputMaybe; }; +export type TimeInterval = + | { aligned: AlignedIntervalEnum; timedelta?: never } + | { aligned?: never; timedelta: TimeDeltaGql }; + export type TooManyInitUploadsErr = { __typename?: "TooManyInitUploadsErr"; linksRequested: Scalars["Int"]["output"]; diff --git a/src/schema.gql b/src/schema.gql index 08638e2..cfedad2 100644 --- a/src/schema.gql +++ b/src/schema.gql @@ -107,26 +107,22 @@ Date with time (isoformat) """ scalar DateTime -input TimeInterval { - """ - A second is the base unit and cannot be subdivided - """ - seconds: Int = 0 - minutes: Int = 0 - hours: Int = 0 +input TimeInterval @oneOf { + timedelta: TimeDeltaGQL + aligned: AlignedIntervalEnum +} + +input TimeDeltaGQL { days: Int = 0 weeks: Int = 0 months: Int = 0 - - """ - Assumes a year is 365 days long - """ years: Int = 0 +} - """ - True eg 1/15-3/15 => [(1/15,1/31), (2/1,2/28), (3/1,3/15)] False eg 1/15-2/15 => [(1/15,2/14), (2/14,3/15)] - """ - calendarAlignedMonths: Boolean! = true +enum AlignedIntervalEnum { + MONTH + YEAR + WEEK } input FilterInput @oneOf {