Updated meilisearch types

This commit is contained in:
DrMint 2024-07-14 17:04:57 +02:00
parent 824f7085f9
commit 806543a487
3 changed files with 87 additions and 44 deletions

3
meilisearch/constants.ts Normal file
View File

@ -0,0 +1,3 @@
export enum MeiliIndexes {
DOCUMENT = "DOCUMENT",
}

View File

@ -11,54 +11,94 @@ import type {
EndpointChronologyEvent, EndpointChronologyEvent,
} from "../payload/endpoint-types"; } from "../payload/endpoint-types";
export type MeiliDocument = { export type MeiliDocumentRequest =
meilid: string; | {
id: string; slug: string;
type: Collections.Collectibles;
}
| {
slug: string;
type: Collections.Pages;
}
| {
slug: string;
type: Collections.Folders;
}
| {
id: string;
type: Collections.Videos;
}
| {
id: string;
type: Collections.Audios;
}
| {
id: string;
type: Collections.Images;
}
| {
id: string;
type: Collections.Files;
}
| {
id: string;
type: Collections.Recorders;
}
| {
id: string;
type: Collections.ChronologyEvents;
};
export type MeiliDocument = MeiliDocumentRequest & {
docId: string;
distinctId: string;
languages: string[]; languages: string[];
title?: string; title?: string;
content?: string; content?: string;
updatedAt?: number; updatedAt?: number;
endpointCalled: string;
} & ( } & (
| { | {
type: Collections.Collectibles; type: Collections.Collectibles;
data: EndpointCollectible; data: EndpointCollectible;
} }
| { | {
type: Collections.Pages; type: Collections.Pages;
data: EndpointPage; data: EndpointPage;
} }
| { | {
type: Collections.Folders; type: Collections.Folders;
data: EndpointFolder; data: EndpointFolder;
} }
| { | {
type: Collections.Videos; type: Collections.Videos;
data: EndpointVideo; data: EndpointVideo;
} }
| { | {
type: Collections.Audios; type: Collections.Audios;
data: EndpointAudio; data: EndpointAudio;
} }
| { | {
type: Collections.Images; type: Collections.Images;
data: EndpointImage; data: EndpointImage;
} }
| { | {
type: Collections.Files; type: Collections.Files;
data: EndpointFile; data: EndpointFile;
} }
| { | {
type: Collections.Recorders; type: Collections.Recorders;
data: EndpointRecorder; data: EndpointRecorder;
} }
| { | {
type: Collections.ChronologyEvents; type: Collections.ChronologyEvents;
data: { data: {
date: EndpointChronologyEvent["date"]; date: EndpointChronologyEvent["date"];
event: EndpointChronologyEvent["events"][number]; event: EndpointChronologyEvent["events"][number];
}; };
} }
); );
export type SearchResponse<T> = { export type SearchResponse<T> = {
hits: T[]; hits: T[];

View File

@ -51,7 +51,7 @@ export const getSDKEndpoint = {
getLoginEndpoint: () => `/${Collections.Recorders}/login`, getLoginEndpoint: () => `/${Collections.Recorders}/login`,
}; };
type PayloadSDKResponse<T> = { export type PayloadSDKResponse<T> = {
data: T; data: T;
endpointCalled: string; endpointCalled: string;
}; };