Skip to content

Commit

Permalink
Add default parameters for AggregationInput and Output #10101
Browse files Browse the repository at this point in the history
`never` is used as the default type parameter for the `aggregation`
properties in the different QueryParams.

`undefined` is used as the default type parameter for `aggregations`
in different query results. The reason `never` is not used is that
since the property is not optional, we are not able to construct this
object independently of the library functions.

(cherry picked from commit 8d1c425)
  • Loading branch information
tajakobsen authored and rymsha committed Apr 5, 2023
1 parent 6d21006 commit f6f273c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions modules/lib/lib-content/src/main/resources/lib/xp/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ export {

export interface ContentsResult<
Hit extends Content<unknown>,
AggregationOutput extends Record<string, AggregationsResult>
AggregationOutput extends Record<string, AggregationsResult> | undefined = undefined
> {
total: number;
count: number;
Expand Down Expand Up @@ -608,7 +608,7 @@ export function create<
return __.toNativeObject(bean.execute<Data, Type>());
}

export interface QueryContentParams<AggregationInput extends Aggregations> {
export interface QueryContentParams<AggregationInput extends Aggregations = never> {
start?: number;
count?: number;
query?: QueryDsl | string;
Expand Down
6 changes: 3 additions & 3 deletions modules/lib/lib-node/src/main/resources/lib/xp/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,15 @@ export interface SuggestionResult {
}[];
}

export interface NodeQueryResult<AggregationOutput extends Record<string, AggregationsResult>> {
export interface NodeQueryResult<AggregationOutput extends Record<string, AggregationsResult> | undefined = undefined> {
total: number;
count: number;
hits: NodeQueryResultHit[];
aggregations: AggregationOutput;
suggestions?: Record<string, SuggestionResult[]>;
}

export interface NodeMultiRepoQueryResult<AggregationOutput extends Record<string, AggregationsResult>> {
export interface NodeMultiRepoQueryResult<AggregationOutput extends Record<string, AggregationsResult> | undefined = undefined> {
total: number;
count: number;
hits: (NodeQueryResultHit & {
Expand Down Expand Up @@ -346,7 +346,7 @@ export interface SetChildOrderParams {
childOrder: string;
}

export interface QueryNodeParams<AggregationInput extends Aggregations> {
export interface QueryNodeParams<AggregationInput extends Aggregations = never> {
start?: number;
count?: number;
query?: QueryDsl | string;
Expand Down

0 comments on commit f6f273c

Please sign in to comment.