From 806543a487319e56cb9f678c9c3a35666f90b82a Mon Sep 17 00:00:00 2001 From: DrMint <29893320+DrMint@users.noreply.github.com> Date: Sun, 14 Jul 2024 17:04:57 +0200 Subject: [PATCH] Updated meilisearch types --- meilisearch/constants.ts | 3 + meilisearch/types.ts | 126 ++++++++++++++++++++++++++------------- payload/sdk.ts | 2 +- 3 files changed, 87 insertions(+), 44 deletions(-) create mode 100644 meilisearch/constants.ts diff --git a/meilisearch/constants.ts b/meilisearch/constants.ts new file mode 100644 index 0000000..2ac5471 --- /dev/null +++ b/meilisearch/constants.ts @@ -0,0 +1,3 @@ +export enum MeiliIndexes { + DOCUMENT = "DOCUMENT", +} \ No newline at end of file diff --git a/meilisearch/types.ts b/meilisearch/types.ts index 7fa3cc3..cf6585f 100644 --- a/meilisearch/types.ts +++ b/meilisearch/types.ts @@ -11,54 +11,94 @@ import type { EndpointChronologyEvent, } from "../payload/endpoint-types"; -export type MeiliDocument = { - meilid: string; - id: string; +export type MeiliDocumentRequest = + | { + 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[]; title?: string; content?: string; updatedAt?: number; + endpointCalled: string; } & ( - | { - type: Collections.Collectibles; - data: EndpointCollectible; - } - | { - type: Collections.Pages; - data: EndpointPage; - } - | { - type: Collections.Folders; - data: EndpointFolder; - } - | { - type: Collections.Videos; - data: EndpointVideo; - } - | { - type: Collections.Audios; - data: EndpointAudio; - } - | { - type: Collections.Images; - data: EndpointImage; - } - | { - type: Collections.Files; - data: EndpointFile; - } - | { - type: Collections.Recorders; - data: EndpointRecorder; - } - | { - type: Collections.ChronologyEvents; - data: { - date: EndpointChronologyEvent["date"]; - event: EndpointChronologyEvent["events"][number]; - }; - } -); + | { + type: Collections.Collectibles; + data: EndpointCollectible; + } + | { + type: Collections.Pages; + data: EndpointPage; + } + | { + type: Collections.Folders; + data: EndpointFolder; + } + | { + type: Collections.Videos; + data: EndpointVideo; + } + | { + type: Collections.Audios; + data: EndpointAudio; + } + | { + type: Collections.Images; + data: EndpointImage; + } + | { + type: Collections.Files; + data: EndpointFile; + } + | { + type: Collections.Recorders; + data: EndpointRecorder; + } + | { + type: Collections.ChronologyEvents; + data: { + date: EndpointChronologyEvent["date"]; + event: EndpointChronologyEvent["events"][number]; + }; + } + ); export type SearchResponse = { hits: T[]; diff --git a/payload/sdk.ts b/payload/sdk.ts index d1602b8..c40ea6e 100644 --- a/payload/sdk.ts +++ b/payload/sdk.ts @@ -51,7 +51,7 @@ export const getSDKEndpoint = { getLoginEndpoint: () => `/${Collections.Recorders}/login`, }; -type PayloadSDKResponse = { +export type PayloadSDKResponse = { data: T; endpointCalled: string; };