@@ -16,8 +16,8 @@ Represents "Order By".
1616## TypeScript Usage
1717
1818``` typescript
19- import { AggregationFunction , AggregationNode , FieldNode , FullTextSearch , JoinNode , JoinStrategy , JoinType , Query , SortNode , WindowFunction , WindowFunctionNode , WindowSpec } from ' @objectstack/spec/data' ;
20- import type { AggregationFunction , AggregationNode , FieldNode , FullTextSearch , JoinNode , JoinStrategy , JoinType , Query , SortNode , WindowFunction , WindowFunctionNode , WindowSpec } from ' @objectstack/spec/data' ;
19+ import { AggregationFunction , AggregationNode , DateGranularity , FieldNode , FullTextSearch , GroupByNode , JoinNode , JoinStrategy , JoinType , Query , SortNode , WindowFunction , WindowFunctionNode , WindowSpec } from ' @objectstack/spec/data' ;
20+ import type { AggregationFunction , AggregationNode , DateGranularity , FieldNode , FullTextSearch , GroupByNode , JoinNode , JoinStrategy , JoinType , Query , SortNode , WindowFunction , WindowFunctionNode , WindowSpec } from ' @objectstack/spec/data' ;
2121
2222// Validate data
2323const result = AggregationFunction .parse (data );
@@ -54,6 +54,19 @@ const result = AggregationFunction.parse(data);
5454| ** filter** | ` [__schema0](./__schema0) ` | optional | Filter/Condition to apply to the aggregation (FILTER WHERE clause) |
5555
5656
57+ ---
58+
59+ ## DateGranularity
60+
61+ ### Allowed Values
62+
63+ * ` day `
64+ * ` week `
65+ * ` month `
66+ * ` quarter `
67+ * ` year `
68+
69+
5770---
5871
5972## FieldNode
@@ -99,6 +112,33 @@ Type: `string`
99112| ** highlight** | ` boolean ` | ✅ | Enable search result highlighting |
100113
101114
115+ ---
116+
117+ ## GroupByNode
118+
119+ ### Union Options
120+
121+ This schema accepts one of the following structures:
122+
123+ #### Option 1
124+
125+ Type: ` string `
126+
127+ ---
128+
129+ #### Option 2
130+
131+ ### Properties
132+
133+ | Property | Type | Required | Description |
134+ | :--- | :--- | :--- | :--- |
135+ | ** field** | ` string ` | ✅ | Field to group by |
136+ | ** dateGranularity** | ` Enum<'day' \| 'week' \| 'month' \| 'quarter' \| 'year'> ` | optional | Bucket date values into uniform periods (day/week/month/quarter/year) |
137+ | ** alias** | ` string ` | optional | Alias for the projected group value |
138+
139+ ---
140+
141+
102142---
103143
104144## JoinNode
@@ -158,7 +198,7 @@ Type: `string`
158198| ** cursor** | ` Record<string, any> ` | optional | Cursor for keyset pagination |
159199| ** joins** | ` Object[] ` | optional | Explicit Table Joins |
160200| ** aggregations** | ` Object[] ` | optional | Aggregation functions |
161- | ** groupBy** | ` string[] ` | optional | GROUP BY fields |
201+ | ** groupBy** | ` string \| Object [] ` | optional | GROUP BY targets (strings or `` {field, dateGranularity?} `` objects for date bucketing) |
162202| ** having** | ` [__schema1](./__schema1) ` | optional | HAVING clause for aggregation filtering |
163203| ** windowFunctions** | ` Object[] ` | optional | Window functions with OVER clause |
164204| ** distinct** | ` boolean ` | optional | SELECT DISTINCT flag |
0 commit comments