@@ -2,9 +2,20 @@ import type { InstanceOptions, IOContext } from '@vtex/api'
22import { ExternalClient } from '@vtex/api'
33
44import { parseState } from '../utils/searchState'
5- import type { IIntelligentSearchClient } from './intsch/types'
6-
7- const isPathTraversal = ( str : string ) => str . indexOf ( '..' ) >= 0
5+ import type {
6+ FetchBannersArgs ,
7+ IIntelligentSearchClient ,
8+ FetchProductArgs ,
9+ FetchProductResponse ,
10+ AutocompleteSuggestionsResponse ,
11+ CorrectionResponse ,
12+ FetchBannersResponse ,
13+ SearchSuggestionsResponse ,
14+ TopSearchesResponse ,
15+ } from './intsch/types'
16+ import type { Options , SearchResultArgs } from '../typings/Search'
17+
18+ export const isPathTraversal = ( str : string ) => str . indexOf ( '..' ) >= 0
819
920interface CorrectionParams {
1021 query : string
@@ -18,11 +29,7 @@ interface AutocompleteSearchSuggestionsParams {
1829 query : string
1930}
2031
21- interface BannersArgs {
22- query : string
23- }
24-
25- interface FacetsArgs {
32+ export type FacetsArgs = {
2633 query ?: string
2734 page ?: number
2835 count ?: number
@@ -40,7 +47,7 @@ interface FacetsArgs {
4047 regionId ?: string | null
4148}
4249
43- const decodeQuery = ( query : string ) => {
50+ export const decodeQuery = ( query : string ) => {
4451 try {
4552 return decodeURIComponent ( query )
4653 } catch ( e ) {
@@ -54,7 +61,7 @@ export class IntelligentSearchApi
5461{
5562 private locale : string | undefined
5663
57- public constructor ( context : IOContext , options ?: InstanceOptions ) {
64+ constructor ( context : IOContext , options ?: InstanceOptions ) {
5865 super (
5966 `http://${ context . workspace } --${ context . account } .myvtex.com/_v/api/intelligent-search` ,
6067 context ,
@@ -103,13 +110,13 @@ export class IntelligentSearchApi
103110 } )
104111 }
105112
106- public async banners ( params : BannersArgs , path : string ) {
107- if ( isPathTraversal ( path ) ) {
113+ public async fetchBanners ( params : FetchBannersArgs ) {
114+ if ( isPathTraversal ( params . path ) ) {
108115 throw new Error ( 'Malformed URL' )
109116 }
110117
111- return this . http . get ( `/banners/${ path } ` , {
112- params : { ... params , query : params . query , locale : this . locale } ,
118+ return this . http . get ( `/banners/${ params . path } ` , {
119+ params : { query : params . query , locale : this . locale } ,
113120 metric : 'banners' ,
114121 } )
115122 }
@@ -130,7 +137,6 @@ export class IntelligentSearchApi
130137 ...params ,
131138 query : query && decodeQuery ( query ) ,
132139 locale : this . locale ,
133- // eslint-disable-next-line @typescript-eslint/camelcase
134140 bgy_leap : leap ? true : undefined ,
135141 ...parseState ( searchState ) ,
136142 } ,
@@ -156,7 +162,6 @@ export class IntelligentSearchApi
156162 params : {
157163 query : query && decodeQuery ( query ) ,
158164 locale : this . locale ,
159- // eslint-disable-next-line @typescript-eslint/camelcase
160165 bgy_leap : leap ? true : undefined ,
161166 ...parseState ( searchState ) ,
162167 ...params ,
@@ -183,7 +188,6 @@ export class IntelligentSearchApi
183188 params : {
184189 query : query && decodeQuery ( query ) ,
185190 locale : this . locale ,
186- // eslint-disable-next-line @typescript-eslint/camelcase
187191 bgy_leap : leap ? true : undefined ,
188192 ...parseState ( searchState ) ,
189193 ...params ,
@@ -194,4 +198,30 @@ export class IntelligentSearchApi
194198 } ,
195199 } )
196200 }
201+
202+ public async fetchAutocompleteSuggestionsV1 ( ) : Promise < AutocompleteSuggestionsResponse > {
203+ throw new Error ( 'Method not implemented.' )
204+ }
205+
206+ public async fetchTopSearchesV1 ( ) : Promise < TopSearchesResponse > {
207+ throw new Error ( 'Method not implemented.' )
208+ }
209+
210+ public async fetchSearchSuggestionsV1 ( ) : Promise < SearchSuggestionsResponse > {
211+ throw new Error ( 'Method not implemented.' )
212+ }
213+
214+ public async fetchCorrectionV1 ( ) : Promise < CorrectionResponse > {
215+ throw new Error ( 'Method not implemented.' )
216+ }
217+
218+ public async fetchBannersV1 ( ) : Promise < FetchBannersResponse > {
219+ throw new Error ( 'Method not implemented.' )
220+ }
221+
222+ public async fetchProduct (
223+ _ : FetchProductArgs
224+ ) : Promise < FetchProductResponse > {
225+ throw new Error ( 'Method not implemented.' )
226+ }
197227}
0 commit comments