@@ -59,8 +59,8 @@ type SelectionResultByLimit = {
5959 all ?: KnockGuideSelectionResult ;
6060} ;
6161type SelectionResultByQuery = {
62- key ?: SelectionResultByLimit ;
63- type ?: SelectionResultByLimit ;
62+ byKey ?: SelectionResultByLimit ;
63+ byType ?: SelectionResultByLimit ;
6464} ;
6565type SelectableStatusPresent = {
6666 status : "returned" | "throttled" | "queried" ;
@@ -157,8 +157,8 @@ const inferSelectByKeyReturnStatus = (
157157 query : SelectionResultByQuery ,
158158) : SelectableStatusPresent [ "status" ] => {
159159 const includeThrottled =
160- ! ! query . key ?. one ?. metadata ?. opts ?. includeThrottled ||
161- ! ! query . key ?. all ?. metadata ?. opts ?. includeThrottled ;
160+ ! ! query . byKey ?. one ?. metadata ?. opts ?. includeThrottled ||
161+ ! ! query . byKey ?. all ?. metadata ?. opts ?. includeThrottled ;
162162
163163 // If unthrottled, then it should always be returned.
164164 if ( guide . bypass_global_group_limit ) {
@@ -185,9 +185,10 @@ const inferSelectOneByTypeReturnStatus = (
185185 stage : KnockGuideClientGroupStage ,
186186 query : SelectionResultByQuery ,
187187) : SelectableStatusPresent [ "status" ] => {
188- const includeThrottled = ! ! query . type ?. one ?. metadata ?. opts ?. includeThrottled ;
188+ const includeThrottled =
189+ ! ! query . byType ?. one ?. metadata ?. opts ?. includeThrottled ;
189190
190- const result = query . type ! . one ! ;
191+ const result = query . byType ! . one ! ;
191192 if ( result . size === 0 ) {
192193 return "queried" ;
193194 }
@@ -229,7 +230,7 @@ const inferSelectAllByTypeReturnStatus = (
229230 stage : KnockGuideClientGroupStage ,
230231 query : SelectionResultByQuery ,
231232) : SelectableStatusPresent [ "status" ] => {
232- const result = query . type ! . all ! ;
233+ const result = query . byType ! . all ! ;
233234 if ( result . size === 0 ) {
234235 return "queried" ;
235236 }
@@ -241,7 +242,8 @@ const inferSelectAllByTypeReturnStatus = (
241242 const guidesByKey : Record < KnockGuide [ "key" ] , KnockGuide > = byKey ( guides ) ;
242243
243244 // If includeThrottled given, then expect all selected guides to be returned.
244- const includeThrottled = ! ! query . type ?. all ?. metadata ?. opts ?. includeThrottled ;
245+ const includeThrottled =
246+ ! ! query . byType ?. all ?. metadata ?. opts ?. includeThrottled ;
245247 if ( includeThrottled ) {
246248 return guidesByKey [ guide . key ] ? "returned" : "queried" ;
247249 }
@@ -270,14 +272,14 @@ const inferSelectReturnStatus = (
270272) => {
271273 // Querying by key can only return up to a max of one guide, regardless of
272274 // useGuide or useGuides, and should take precedence in status designation.
273- if ( query . key ) {
275+ if ( query . byKey ) {
274276 return inferSelectByKeyReturnStatus ( guide , snapshot , stage , query ) ;
275277 }
276278
277- if ( query . type ?. all ) {
279+ if ( query . byType ?. all ) {
278280 return inferSelectAllByTypeReturnStatus ( guide , snapshot , stage , query ) ;
279281 }
280- if ( query . type ?. one ) {
282+ if ( query . byType ?. one ) {
281283 return inferSelectOneByTypeReturnStatus ( guide , snapshot , stage , query ) ;
282284 }
283285
@@ -295,11 +297,11 @@ const toSelectableStatus = (
295297 }
296298
297299 const query = {
298- key : ( stage . results . key || { } ) [ guide . key ] ,
299- type : ( stage . results . type || { } ) [ guide . type ] ,
300+ byKey : ( stage . results . byKey || { } ) [ guide . key ] ,
301+ byType : ( stage . results . byType || { } ) [ guide . type ] ,
300302 } ;
301303
302- const queried = Boolean ( query . key || query . type ) ;
304+ const queried = Boolean ( query . byKey || query . byType ) ;
303305 if ( ! queried ) {
304306 // No present query in the current location can select this guide.
305307 return { status : undefined } ;
0 commit comments