diff --git a/types/index.d.ts b/types/index.d.ts index 1ffeee6..3a5fa8b 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -881,6 +881,55 @@ declare namespace CbServer { changes: Partial, uniquelyIndexedColumn: string ): Promise>>; + createContinuousAggregate( + query: string, + options: ContinuousAggregateOptions, + ): Promise; + fetchAggregateRaw( + aggregateName: string, + query: string, + ): Promise>>; + dropContinuousAggregate(aggregateName: string): Promise; + } + + /** + * Must be of one of the following forms: + * - "1 second", "1 hour", "1 day", "1 month", "1 year" + * - "X seconds", "X hours", "X days", "X months", "X years" where X > 1 + */ + type TimescaleInterval = + | "1 second" + | "1 hour" + | "1 day" + | "1 month" + | "1 year" + | `${number} seconds` + | `${number} hours` + | `${number} days` + | `${number} months` + | `${number} years`; + + interface ContinuousAggregateOptions { + /** + * The name of the continuous aggregate + */ + view_name: string; + /** + * The offset from the current date to begin aggregating data (Ex. "1 month") + */ + start_offset: TimescaleInterval; + /** + * The offset from the current date to stop aggregating data (Ex. "12 hours") + */ + end_offset: TimescaleInterval; + /** + * The interval at which to recompute the continuous aggregate (Ex. "1 hour") + */ + schedule_interval: TimescaleInterval; + /** + * If set to true, the aggregate will be created without initially calculating the aggregate value + */ + with_no_data: boolean; } interface CustomSyncAsync {