|
1 |
| -import { AxiosError, AxiosInstance, CancelTokenSource, AxiosRequestConfig, AxiosResponse } from 'axios' |
| 1 | +import { |
| 2 | + AxiosError, |
| 3 | + AxiosInstance, |
| 4 | + AxiosRequestConfig, |
| 5 | + AxiosResponse, |
| 6 | + CancelTokenSource, |
| 7 | +} from 'axios' |
2 | 8 |
|
3 | 9 | ///
|
4 | 10 | /// Global interfaces
|
@@ -203,127 +209,126 @@ export interface SysInfoPretty {
|
203 | 209 | ** MeiliSearch Class
|
204 | 210 | */
|
205 | 211 |
|
206 |
| - |
207 |
| -export interface Indexes extends MeiliAxiosWrapper{ |
208 |
| - indexUid: string; |
209 |
| - getUpdateStatus(updateId: number): Promise<Update>; |
210 |
| - getAllUpdateStatus(): Promise<Update[]>; |
211 |
| - search(query: string, options?: SearchParams): Promise<SearchResponse>; |
212 |
| - show(): Promise<Index>; |
213 |
| - updateIndex(data: UpdateIndexRequest): Promise<Index>; |
214 |
| - deleteIndex(): Promise<string>; |
215 |
| - getStats(): Promise<IndexStats>; |
216 |
| - getDocuments(options?: GetDocumentsParams): Promise<Document[]>; |
217 |
| - getDocument(documentId: string | number): Promise<Document>; |
| 212 | +export interface Indexes extends MeiliAxiosWrapper { |
| 213 | + indexUid: string |
| 214 | + getUpdateStatus(updateId: number): Promise<Update> |
| 215 | + getAllUpdateStatus(): Promise<Update[]> |
| 216 | + search(query: string, options?: SearchParams): Promise<SearchResponse> |
| 217 | + show(): Promise<Index> |
| 218 | + updateIndex(data: UpdateIndexRequest): Promise<Index> |
| 219 | + deleteIndex(): Promise<string> |
| 220 | + getStats(): Promise<IndexStats> |
| 221 | + getDocuments(options?: GetDocumentsParams): Promise<Document[]> |
| 222 | + getDocument(documentId: string | number): Promise<Document> |
218 | 223 | addDocuments(
|
219 | 224 | documents: Document[],
|
220 | 225 | options?: AddDocumentParams
|
221 |
| - ): Promise<EnqueuedUpdate>; |
| 226 | + ): Promise<EnqueuedUpdate> |
222 | 227 | updateDocuments(
|
223 | 228 | documents: Document[],
|
224 | 229 | options?: AddDocumentParams
|
225 |
| - ): Promise<EnqueuedUpdate>; |
226 |
| - deleteDocument(documentId: string | number): Promise<EnqueuedUpdate>; |
227 |
| - deleteDocuments(documentsIds: string[] | number[]): Promise<EnqueuedUpdate>; |
228 |
| - deleteAllDocuments(): Promise<EnqueuedUpdate>; |
229 |
| - getSettings(): Promise<Settings>; |
230 |
| - updateSettings(settings: Settings): Promise<EnqueuedUpdate>; |
231 |
| - resetSettings(): Promise<EnqueuedUpdate>; |
232 |
| - getSynonyms(): Promise<object>; |
233 |
| - updateSynonyms(synonyms: object): Promise<object>; |
234 |
| - resetSynonyms(): Promise<object>; |
235 |
| - getStopWords(): Promise<string[]>; |
236 |
| - updateStopWords(stopWords: string[]): Promise<EnqueuedUpdate>; |
237 |
| - resetStopWords(): Promise<EnqueuedUpdate>; |
238 |
| - getRankingRules(): Promise<string[]>; |
239 |
| - updateRankingRules(rankingRules: string[]): Promise<EnqueuedUpdate>; |
240 |
| - resetRankingRules(): Promise<EnqueuedUpdate>; |
241 |
| - getDistinctAttribute(): Promise<string | void>; |
242 |
| - updateDistinctAttribute(distinctAttribute: string): Promise<EnqueuedUpdate>; |
243 |
| - resetDistinctAttribute(): Promise<EnqueuedUpdate>; |
244 |
| - getSearchableAttributes(): Promise<string[]>; |
| 230 | + ): Promise<EnqueuedUpdate> |
| 231 | + deleteDocument(documentId: string | number): Promise<EnqueuedUpdate> |
| 232 | + deleteDocuments(documentsIds: string[] | number[]): Promise<EnqueuedUpdate> |
| 233 | + deleteAllDocuments(): Promise<EnqueuedUpdate> |
| 234 | + getSettings(): Promise<Settings> |
| 235 | + updateSettings(settings: Settings): Promise<EnqueuedUpdate> |
| 236 | + resetSettings(): Promise<EnqueuedUpdate> |
| 237 | + getSynonyms(): Promise<object> |
| 238 | + updateSynonyms(synonyms: object): Promise<object> |
| 239 | + resetSynonyms(): Promise<object> |
| 240 | + getStopWords(): Promise<string[]> |
| 241 | + updateStopWords(stopWords: string[]): Promise<EnqueuedUpdate> |
| 242 | + resetStopWords(): Promise<EnqueuedUpdate> |
| 243 | + getRankingRules(): Promise<string[]> |
| 244 | + updateRankingRules(rankingRules: string[]): Promise<EnqueuedUpdate> |
| 245 | + resetRankingRules(): Promise<EnqueuedUpdate> |
| 246 | + getDistinctAttribute(): Promise<string | void> |
| 247 | + updateDistinctAttribute(distinctAttribute: string): Promise<EnqueuedUpdate> |
| 248 | + resetDistinctAttribute(): Promise<EnqueuedUpdate> |
| 249 | + getSearchableAttributes(): Promise<string[]> |
245 | 250 | updateSearchableAttributes(
|
246 | 251 | searchableAttributes: string[]
|
247 |
| - ): Promise<EnqueuedUpdate>; |
248 |
| - resetSearchableAttributes(): Promise<EnqueuedUpdate>; |
249 |
| - getDisplayedAttributes(): Promise<string[]>; |
| 252 | + ): Promise<EnqueuedUpdate> |
| 253 | + resetSearchableAttributes(): Promise<EnqueuedUpdate> |
| 254 | + getDisplayedAttributes(): Promise<string[]> |
250 | 255 | updateDisplayedAttributes(
|
251 | 256 | displayedAttributes: string[]
|
252 |
| - ): Promise<EnqueuedUpdate>; |
253 |
| - resetDisplayedAttributes(): Promise<EnqueuedUpdate>; |
254 |
| - getAcceptNewFields(): Promise<boolean>; |
255 |
| - updateAcceptNewFields(acceptNewFields: boolean): Promise<EnqueuedUpdate>; |
| 257 | + ): Promise<EnqueuedUpdate> |
| 258 | + resetDisplayedAttributes(): Promise<EnqueuedUpdate> |
| 259 | + getAcceptNewFields(): Promise<boolean> |
| 260 | + updateAcceptNewFields(acceptNewFields: boolean): Promise<EnqueuedUpdate> |
256 | 261 | }
|
257 | 262 |
|
258 |
| -export interface Meilisearch extends MeiliAxiosErrorInterface { |
259 |
| - config: Config; |
260 |
| - getIndex(indexUid: string): Indexes; |
261 |
| - listIndexes(): Promise<IndexResponse[]>; |
262 |
| - createIndex(data: IndexRequest): Promise<IndexResponse>; |
263 |
| - getKeys(): Promise<Keys>; |
264 |
| - isHealthy(): Promise<boolean>; |
265 |
| - setHealthy(): Promise<void>; |
266 |
| - setUnhealthy(): Promise<void>; |
267 |
| - changeHealthTo(health: boolean): Promise<void>; |
268 |
| - stats(): Promise<Stats>; |
269 |
| - version(): Promise<Version>; |
270 |
| - sysInfo(): Promise<SysInfo>; |
271 |
| - prettySysInfo(): Promise<SysInfoPretty>; |
| 263 | +export interface Meilisearch extends MeiliSearchApiErrorInterface { |
| 264 | + config: Config |
| 265 | + getIndex(indexUid: string): Indexes |
| 266 | + listIndexes(): Promise<IndexResponse[]> |
| 267 | + createIndex(data: IndexRequest): Promise<IndexResponse> |
| 268 | + getKeys(): Promise<Keys> |
| 269 | + isHealthy(): Promise<boolean> |
| 270 | + setHealthy(): Promise<void> |
| 271 | + setUnhealthy(): Promise<void> |
| 272 | + changeHealthTo(health: boolean): Promise<void> |
| 273 | + stats(): Promise<Stats> |
| 274 | + version(): Promise<Version> |
| 275 | + sysInfo(): Promise<SysInfo> |
| 276 | + prettySysInfo(): Promise<SysInfoPretty> |
272 | 277 | }
|
273 | 278 |
|
274 | 279 | export interface MeiliAxiosWrapper {
|
275 |
| - instance: AxiosInstance; |
276 |
| - cancelTokenSource: CancelTokenSource; |
| 280 | + instance: AxiosInstance |
| 281 | + cancelTokenSource: CancelTokenSource |
277 | 282 | get<T = any, R = AxiosResponse<T>>(
|
278 | 283 | url: string,
|
279 | 284 | config?: AxiosRequestConfig
|
280 |
| - ): Promise<R>; |
| 285 | + ): Promise<R> |
281 | 286 | post<T = any, R = AxiosResponse<T>>(
|
282 | 287 | url: string,
|
283 | 288 | data?: any,
|
284 | 289 | config?: AxiosRequestConfig
|
285 |
| - ): Promise<R>; |
| 290 | + ): Promise<R> |
286 | 291 | put<T = any, R = AxiosResponse<T>>(
|
287 | 292 | url: string,
|
288 | 293 | data?: any,
|
289 | 294 | config?: AxiosRequestConfig
|
290 |
| - ): Promise<R>; |
| 295 | + ): Promise<R> |
291 | 296 | patch<T = any, R = AxiosResponse<T>>(
|
292 | 297 | url: string,
|
293 | 298 | data?: any,
|
294 | 299 | config?: AxiosRequestConfig
|
295 |
| - ): Promise<R>; |
| 300 | + ): Promise<R> |
296 | 301 | delete<T = any, R = AxiosResponse<T>>(
|
297 | 302 | url: string,
|
298 | 303 | config?: AxiosRequestConfig
|
299 |
| - ): Promise<R>; |
| 304 | + ): Promise<R> |
300 | 305 | }
|
301 | 306 |
|
302 | 307 | /*
|
303 | 308 | ** ERROR HANDLER
|
304 | 309 | */
|
305 | 310 |
|
306 |
| -export interface MeiliAxiosErrorInterface extends Error { |
| 311 | +export interface MeiliSearchApiErrorInterface extends Error { |
307 | 312 | name: string
|
308 | 313 | message: string
|
309 | 314 | stack?: string
|
310 | 315 | }
|
311 |
| -export interface MeiliAxiosErrorResponse { |
| 316 | +export interface MeiliSearchApiErrorResponse { |
312 | 317 | status?: number
|
313 | 318 | statusText?: string
|
314 | 319 | path?: string
|
315 | 320 | method?: string
|
316 | 321 | body?: object
|
317 | 322 | }
|
318 |
| -export interface MeiliAxiosErrorRequest { |
| 323 | +export interface MeiliSearchApiErrorRequest { |
319 | 324 | url?: string
|
320 | 325 | path?: string
|
321 | 326 | method?: string
|
322 | 327 | }
|
323 | 328 |
|
324 |
| -export type MeiliAxiosErrorConstructor = new ( |
| 329 | +export type MeiliSearchApiErrorConstructor = new ( |
325 | 330 | error: AxiosError,
|
326 | 331 | cachedStack?: string
|
327 | 332 | ) => void
|
328 | 333 |
|
329 |
| -export default Indexes; |
| 334 | +export default Indexes |
0 commit comments