typesense
Version:
Javascript Library for Typesense
71 lines (62 loc) • 1.47 kB
text/typescript
import ApiCall from "./ApiCall";
export type CurationRuleSchema =
| {
query: string;
match: "exact" | "contains";
filter_by?: string;
tags?: string[];
}
| {
query?: never;
match?: never;
filter_by: string;
tags?: string[];
}
| {
query?: never;
match?: never;
filter_by?: string;
tags: string[];
};
export interface CurationObjectSchema {
id: string;
rule: CurationRuleSchema;
includes?: {
id: string;
position: number;
}[];
excludes?: {
id: string;
}[];
filter_by?: string;
sort_by?: string;
replace_query?: string;
remove_matched_tokens?: boolean;
filter_curated_hits?: boolean;
stop_processing?: boolean;
effective_from_ts?: number;
effective_to_ts?: number;
metadata?: Record<string, unknown>;
}
export interface CurationSetUpsertSchema {
items: CurationObjectSchema[];
}
export interface CurationSetSchema extends CurationSetUpsertSchema {
name?: string;
}
export interface CurationSetsListEntrySchema {
name: string;
items: CurationObjectSchema[];
}
export interface CurationSetDeleteResponseSchema {
name: string;
}
export default class CurationSets {
constructor(private apiCall: ApiCall) {}
static readonly RESOURCEPATH = "/curation_sets";
async retrieve(): Promise<CurationSetsListEntrySchema[]> {
return this.apiCall.get<CurationSetsListEntrySchema[]>(
CurationSets.RESOURCEPATH,
);
}
}