mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-15 18:25:18 +02:00
feat: add new_mention notification type with metadata schema
This commit is contained in:
parent
2839501503
commit
7b170dfa75
1 changed files with 23 additions and 1 deletions
|
|
@ -5,7 +5,7 @@ import { documentTypeEnum } from "./document.types";
|
||||||
/**
|
/**
|
||||||
* Notification type enum - matches backend notification types
|
* Notification type enum - matches backend notification types
|
||||||
*/
|
*/
|
||||||
export const notificationTypeEnum = z.enum(["connector_indexing", "document_processing"]);
|
export const notificationTypeEnum = z.enum(["connector_indexing", "document_processing", "new_mention"]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notification status enum - used in metadata
|
* Notification status enum - used in metadata
|
||||||
|
|
@ -68,6 +68,20 @@ export const documentProcessingMetadata = baseNotificationMetadata.extend({
|
||||||
error_message: z.string().nullable().optional(),
|
error_message: z.string().nullable().optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* New mention metadata schema
|
||||||
|
*/
|
||||||
|
export const newMentionMetadata = z.object({
|
||||||
|
mention_id: z.number(),
|
||||||
|
comment_id: z.number(),
|
||||||
|
message_id: z.number(),
|
||||||
|
thread_id: z.number(),
|
||||||
|
thread_title: z.string(),
|
||||||
|
author_id: z.string(),
|
||||||
|
author_name: z.string(),
|
||||||
|
content_preview: z.string(),
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Union of all notification metadata types
|
* Union of all notification metadata types
|
||||||
* Use this when the notification type is unknown
|
* Use this when the notification type is unknown
|
||||||
|
|
@ -75,6 +89,7 @@ export const documentProcessingMetadata = baseNotificationMetadata.extend({
|
||||||
export const notificationMetadata = z.union([
|
export const notificationMetadata = z.union([
|
||||||
connectorIndexingMetadata,
|
connectorIndexingMetadata,
|
||||||
documentProcessingMetadata,
|
documentProcessingMetadata,
|
||||||
|
newMentionMetadata,
|
||||||
baseNotificationMetadata,
|
baseNotificationMetadata,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
@ -107,6 +122,11 @@ export const documentProcessingNotification = notification.extend({
|
||||||
metadata: documentProcessingMetadata,
|
metadata: documentProcessingMetadata,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const newMentionNotification = notification.extend({
|
||||||
|
type: z.literal("new_mention"),
|
||||||
|
metadata: newMentionMetadata,
|
||||||
|
});
|
||||||
|
|
||||||
// Inferred types
|
// Inferred types
|
||||||
export type NotificationTypeEnum = z.infer<typeof notificationTypeEnum>;
|
export type NotificationTypeEnum = z.infer<typeof notificationTypeEnum>;
|
||||||
export type NotificationStatusEnum = z.infer<typeof notificationStatusEnum>;
|
export type NotificationStatusEnum = z.infer<typeof notificationStatusEnum>;
|
||||||
|
|
@ -114,7 +134,9 @@ export type DocumentProcessingStageEnum = z.infer<typeof documentProcessingStage
|
||||||
export type BaseNotificationMetadata = z.infer<typeof baseNotificationMetadata>;
|
export type BaseNotificationMetadata = z.infer<typeof baseNotificationMetadata>;
|
||||||
export type ConnectorIndexingMetadata = z.infer<typeof connectorIndexingMetadata>;
|
export type ConnectorIndexingMetadata = z.infer<typeof connectorIndexingMetadata>;
|
||||||
export type DocumentProcessingMetadata = z.infer<typeof documentProcessingMetadata>;
|
export type DocumentProcessingMetadata = z.infer<typeof documentProcessingMetadata>;
|
||||||
|
export type NewMentionMetadata = z.infer<typeof newMentionMetadata>;
|
||||||
export type NotificationMetadata = z.infer<typeof notificationMetadata>;
|
export type NotificationMetadata = z.infer<typeof notificationMetadata>;
|
||||||
export type Notification = z.infer<typeof notification>;
|
export type Notification = z.infer<typeof notification>;
|
||||||
export type ConnectorIndexingNotification = z.infer<typeof connectorIndexingNotification>;
|
export type ConnectorIndexingNotification = z.infer<typeof connectorIndexingNotification>;
|
||||||
export type DocumentProcessingNotification = z.infer<typeof documentProcessingNotification>;
|
export type DocumentProcessingNotification = z.infer<typeof documentProcessingNotification>;
|
||||||
|
export type NewMentionNotification = z.infer<typeof newMentionNotification>;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue