Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/Typesense/CurationSet.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import ApiCall from "./ApiCall";
import CurationSets, {
import CurationSets from "./CurationSets";
import type {
CurationSetDeleteResponseSchema,
CurationSetSchema,
CurationSetUpsertSchema,
Expand All @@ -11,7 +12,10 @@ export default class CurationSet {
private readonly _items: CurationSetItems;
private individualItems: Record<string, CurationSetItem> = {};

constructor(private name: string, private apiCall: ApiCall) {
constructor(
private name: string,
private apiCall: ApiCall,
) {
this._items = new CurationSetItems(this.name, apiCall);
}

Expand Down Expand Up @@ -50,5 +54,3 @@ export default class CurationSet {
return `${CurationSets.RESOURCEPATH}/${encodeURIComponent(this.name)}`;
}
}


5 changes: 2 additions & 3 deletions src/Typesense/CurationSetItem.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import ApiCall from "./ApiCall";
import CurationSets, { CurationObjectSchema } from "./CurationSets";
import CurationSets from "./CurationSets";
import type { CurationObjectSchema } from "./CurationSets";

export interface CurationItemDeleteResponseSchema {
id: string;
Expand Down Expand Up @@ -32,5 +33,3 @@ export default class CurationSetItem {
)}/items/${encodeURIComponent(this.itemId)}`;
}
}


45 changes: 21 additions & 24 deletions src/Typesense/CurationSets.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
import ApiCall from "./ApiCall";

export interface CurationIncludeSchema {
id: string;
position: number;
}

export interface CurationExcludeSchema {
id: string;
}

export interface CurationRuleSchema {
query?: string;
match?: "exact" | "contains";
filter_by?: string;
tags?: string[];
}
export type CurationRuleSchema =
| { tags: string[]; query?: never; match?: never; filter_by?: never }
| {
query: string;
match: "exact" | "contains";
tags?: never;
filter_by?: never;
}
| { filter_by: string; tags?: never; query?: never; match?: never };

export interface CurationObjectSchema {
id: string;
rule?: CurationRuleSchema;
includes?: CurationIncludeSchema[];
excludes?: CurationExcludeSchema[];
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>;
}

Expand All @@ -43,8 +44,6 @@ export interface CurationSetsListEntrySchema {
items: CurationObjectSchema[];
}

export type CurationSetsListResponseSchema = CurationSetsListEntrySchema[];

export interface CurationSetDeleteResponseSchema {
name: string;
}
Expand All @@ -53,11 +52,9 @@ export default class CurationSets {
constructor(private apiCall: ApiCall) {}
static readonly RESOURCEPATH = "/curation_sets";

async retrieve(): Promise<CurationSetsListResponseSchema> {
return this.apiCall.get<CurationSetsListResponseSchema>(
async retrieve(): Promise<CurationSetsListEntrySchema[]> {
return this.apiCall.get<CurationSetsListEntrySchema[]>(
CurationSets.RESOURCEPATH,
);
}
}


Loading