typesense / typesense-js

JavaScript / TypeScript client for Typesense
https://typesense.org/docs/api
Apache License 2.0
393 stars 74 forks source link

Multi-search response type mismatch (`collection_name` missing from `request_params`) #169

Closed rosslavery closed 9 months ago

rosslavery commented 1 year ago

Description

When making a multi-search request, the response from the server contains collection_name

image

This is absent from the Typescript types that repurpose the SearchResponse type which references SearchParams, which has no collection_name property.

export interface MultiSearchResponse<T extends DocumentSchema[] = []> {
    results: {
        [Index in keyof T]: SearchResponse<T[Index]>;
    } & {
        length: T["length"];
    };
}
export interface SearchResponse<T extends DocumentSchema> {
    facet_counts?: SearchResponseFacetCountSchema<T>[];
    found: number;
    out_of: number;
    page: number;
    request_params: SearchParams | SearchParamsWithPreset;
    search_time_ms: number;
    hits?: SearchResponseHit<T>[];
    grouped_hits?: {
        group_key: string[];
        hits: SearchResponseHit<T>[];
    }[];
}

Expected Behavior

To have the types be correct :D

Actual Behavior

Wrong types!

jasonbosco commented 10 months ago

@rosslavery Could you try with 1.7.2-4?

rosslavery commented 9 months ago

Resolved in this PR + 1.7.2, closing this out. Thank you!