File tree Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -19,10 +19,17 @@ export type ApiAskModeResponse = {
1919 sources ?: ApiSource [ ] ;
2020} ;
2121
22+ export type ApiQuerySort = {
23+ property_name : string ;
24+ order : "ascending" | "descending" ;
25+ tie_break ?: ApiQuerySort ;
26+ } ;
27+
2228export type ApiSearch = {
2329 query ?: string ;
2430 filters ?: ApiPropertyFilter | ApiFilterAndOr ;
2531 collection : string ;
32+ sort_property ?: ApiQuerySort ;
2633} ;
2734
2835export type ApiAggregation = {
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import {
1616 AskModeResponse ,
1717 Search ,
1818 ModelUnitUsage ,
19+ QuerySort ,
1920} from "./response.js" ;
2021
2122import {
@@ -32,6 +33,7 @@ import {
3233 ApiAskModeResponse ,
3334 ApiSearch ,
3435 ApiModelUnitUsage ,
36+ ApiQuerySort ,
3537} from "./api-response.js" ;
3638
3739import { ServerSentEvent } from "./server-sent-events.js" ;
@@ -67,8 +69,17 @@ const mapSearches = (searches: ApiSearch[]): Search[] =>
6769 query : search . query ,
6870 filters : search . filters ? mapFilter ( search . filters ) : undefined ,
6971 collection : search . collection ,
72+ sortProperty : search . sort_property
73+ ? mapQuerySort ( search . sort_property )
74+ : undefined ,
7075 } ) ) ;
7176
77+ const mapQuerySort = ( sort : ApiQuerySort ) : QuerySort => ( {
78+ propertyName : sort . property_name ,
79+ order : sort . order ,
80+ tieBreak : sort . tie_break ? mapQuerySort ( sort . tie_break ) : undefined ,
81+ } ) ;
82+
7283const mapUsage = ( usage : ApiModelUnitUsage ) : ModelUnitUsage => ( {
7384 modelUnits : usage . model_units ,
7485 usageInPlan : usage . usage_in_plan ,
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ export type Search = {
1717 query ?: string ;
1818 filters ?: PropertyFilter | FilterAndOr ;
1919 collection : string ;
20+ sortProperty ?: QuerySort ;
2021} ;
2122
2223export type Aggregation = {
@@ -37,6 +38,12 @@ export type ModelUnitUsage = {
3738 remainingPlanRequests : number ;
3839} ;
3940
41+ export type QuerySort = {
42+ propertyName : string ;
43+ order : "ascending" | "descending" ;
44+ tieBreak ?: QuerySort ;
45+ } ;
46+
4047export type QueryAgentResponse = {
4148 outputType : "finalState" ;
4249 originalQuery : string ;
You can’t perform that action at this time.
0 commit comments