good forst commit

This commit is contained in:
2026-06-09 02:02:40 +05:30
parent 801c1d7121
commit 249d759e6a
215 changed files with 15425 additions and 1240 deletions
+10 -2
View File
@@ -4,6 +4,7 @@ export { MeiliSearch } from 'meilisearch';
export interface MeiliDocument {
id: string; // DB Message.id
tenantId: string; // tenant owner — required for multi-tenant filter
content: string;
senderName: string; // empty string when null
sourceGroupId: string;
@@ -20,15 +21,22 @@ export function createMeiliClient(url: string, masterKey: string): MeiliSearch {
}
export async function configureIndex(client: MeiliSearch): Promise<void> {
// Ensure the index exists with the correct primary key
// (Meilisearch v1.11 can't infer it when multiple fields end with `id`)
try {
await client.getIndex(MESSAGES_INDEX);
} catch {
await client.createIndex(MESSAGES_INDEX, { primaryKey: 'id' });
}
await client.index(MESSAGES_INDEX).updateSettings({
searchableAttributes: ['content', 'senderName', 'sourceGroupName'],
filterableAttributes: ['sourceGroupId', 'tags', 'platform'],
filterableAttributes: ['tenantId', 'sourceGroupId', 'tags', 'platform'],
sortableAttributes: ['approvedAt'],
});
}
export async function indexMessage(client: MeiliSearch, doc: MeiliDocument): Promise<void> {
await client.index(MESSAGES_INDEX).addDocuments([doc]);
await client.index(MESSAGES_INDEX).addDocuments([doc], { primaryKey: 'id' });
}
export async function deleteMessage(client: MeiliSearch, id: string): Promise<void> {