@replyke/core
Version:
Replyke: Build interactive apps with social features like comments, votes, feeds, user lists, notifications, and more.
379 lines (378 loc) • 13.9 kB
TypeScript
interface MilestoneUser {
id: string;
name: string | null | undefined;
username: string | null | undefined;
avatar: string | null | undefined;
}
type AppNotificationType = "system" | "entity-comment" | "comment-reply" | "entity-mention" | "comment-mention" | "entity-upvote" | "comment-upvote" | "entity-reaction" | "comment-reaction" | "entity-reaction-milestone-specific" | "entity-reaction-milestone-total" | "comment-reaction-milestone-specific" | "comment-reaction-milestone-total" | "new-follow" | "connection-request" | "connection-accepted" | "space-membership-approved";
interface BaseAppNotification {
id: string;
userId: string;
type: AppNotificationType;
isRead: boolean;
metadata: Record<string, any>;
createdAt: string;
}
export interface SystemNotification extends BaseAppNotification {
type: "system";
action: string;
metadata: {
title?: string;
content?: string;
buttonData: {
text: string;
url: string;
} | null;
};
}
export interface EntityCommentNotification extends BaseAppNotification {
type: "entity-comment";
action: "open-comment";
metadata: {
entityId: string;
entityShortId: string;
entityTitle: string | null | undefined;
entityContent: string | null | undefined;
commentId: string;
commentContent: string | null | undefined;
initiatorId: string;
initiatorName: string | null | undefined;
initiatorUsername: string | null | undefined;
initiatorAvatar: string | null | undefined;
};
}
export interface CommentReplyNotification extends BaseAppNotification {
type: "comment-reply";
action: "open-comment";
metadata: {
entityId: string;
entityShortId: string;
entityTitle: string | null | undefined;
entityContent: string | null | undefined;
commentId: string;
commentContent: string | null | undefined;
replyId: string;
replyContent: string | null | undefined;
initiatorId: string;
initiatorName: string | null | undefined;
initiatorUsername: string | null | undefined;
initiatorAvatar: string | null | undefined;
};
}
export interface EntityMentionNotification extends BaseAppNotification {
type: "entity-mention";
action: "open-entity";
metadata: {
entityId: string;
entityShortId: string;
entityTitle: string | null | undefined;
entityContent: string | null | undefined;
initiatorId: string;
initiatorName: string | null | undefined;
initiatorUsername: string | null | undefined;
initiatorAvatar: string | null | undefined;
};
}
export interface CommentMentionNotification extends BaseAppNotification {
type: "comment-mention";
action: "open-comment";
metadata: {
entityId: string;
entityShortId: string;
entityTitle: string | null | undefined;
entityContent: string | null | undefined;
commentId: string;
commentContent: string | null | undefined;
initiatorId: string;
initiatorName: string | null | undefined;
initiatorUsername: string | null | undefined;
initiatorAvatar: string | null | undefined;
};
}
export interface EntityUpvoteNotification extends BaseAppNotification {
type: "entity-upvote";
action: "open-entity";
metadata: {
entityId: string;
entityShortId: string;
entityTitle: string | null | undefined;
entityContent: string | null | undefined;
initiatorId: string;
initiatorName: string | null | undefined;
initiatorUsername: string | null | undefined;
initiatorAvatar: string | null | undefined;
};
}
export interface CommentUpvoteNotification extends BaseAppNotification {
type: "comment-upvote";
action: "open-comment";
metadata: {
entityId: string;
entityShortId: string;
entityTitle: string | null | undefined;
entityContent: string | null | undefined;
commentId: string;
commentContent: string | null | undefined;
initiatorId: string;
initiatorName: string | null | undefined;
initiatorUsername: string | null | undefined;
initiatorAvatar: string | null | undefined;
};
}
export interface EntityReactionNotification extends BaseAppNotification {
type: "entity-reaction";
action: "open-entity";
metadata: {
entityId: string;
entityShortId: string;
entityTitle: string | null | undefined;
entityContent: string | null | undefined;
reactionType: string;
initiatorId: string;
initiatorName: string | null | undefined;
initiatorUsername: string | null | undefined;
initiatorAvatar: string | null | undefined;
};
}
export interface CommentReactionNotification extends BaseAppNotification {
type: "comment-reaction";
action: "open-comment";
metadata: {
entityId: string;
entityShortId: string;
entityTitle: string | null | undefined;
entityContent: string | null | undefined;
commentId: string;
commentContent: string | null | undefined;
reactionType: string;
initiatorId: string;
initiatorName: string | null | undefined;
initiatorUsername: string | null | undefined;
initiatorAvatar: string | null | undefined;
};
}
export interface EntityReactionMilestoneSpecificNotification extends BaseAppNotification {
type: "entity-reaction-milestone-specific";
action: "open-entity";
metadata: {
entityId: string;
entityShortId: string;
entityTitle: string | null | undefined;
entityContent: string | null | undefined;
reactionType: string;
milestoneCount: number;
lastThreeUsers: MilestoneUser[];
};
}
export interface EntityReactionMilestoneTotalNotification extends BaseAppNotification {
type: "entity-reaction-milestone-total";
action: "open-entity";
metadata: {
entityId: string;
entityShortId: string;
entityTitle: string | null | undefined;
entityContent: string | null | undefined;
milestoneCount: number;
reactionCounts: Record<string, number>;
lastThreeUsers: MilestoneUser[];
};
}
export interface CommentReactionMilestoneSpecificNotification extends BaseAppNotification {
type: "comment-reaction-milestone-specific";
action: "open-comment";
metadata: {
entityId: string;
entityShortId: string;
entityTitle: string | null | undefined;
entityContent: string | null | undefined;
commentId: string;
commentContent: string | null | undefined;
reactionType: string;
milestoneCount: number;
lastThreeUsers: MilestoneUser[];
};
}
export interface CommentReactionMilestoneTotalNotification extends BaseAppNotification {
type: "comment-reaction-milestone-total";
action: "open-comment";
metadata: {
entityId: string;
entityShortId: string;
entityTitle: string | null | undefined;
entityContent: string | null | undefined;
commentId: string;
commentContent: string | null | undefined;
milestoneCount: number;
reactionCounts: Record<string, number>;
lastThreeUsers: MilestoneUser[];
};
}
export interface NewFollowNotification extends BaseAppNotification {
type: "new-follow";
action: "open-profile";
metadata: {
initiatorId: string;
initiatorName: string | null | undefined;
initiatorUsername: string | null | undefined;
initiatorAvatar: string | null | undefined;
};
}
export interface ConnectionRequestNotification extends BaseAppNotification {
type: "connection-request";
action: "open-profile";
metadata: {
connectionId: string;
initiatorId: string;
initiatorName: string | null | undefined;
initiatorUsername: string | null | undefined;
initiatorAvatar: string | null | undefined;
};
}
export interface ConnectionAcceptedNotification extends BaseAppNotification {
type: "connection-accepted";
action: "open-profile";
metadata: {
connectionId: string;
initiatorId: string;
initiatorName: string | null | undefined;
initiatorUsername: string | null | undefined;
initiatorAvatar: string | null | undefined;
};
}
export interface SpaceMembershipApprovedNotification extends BaseAppNotification {
type: "space-membership-approved";
action: "open-space";
metadata: {
spaceId: string;
spaceName: string;
spaceShortId: string;
spaceSlug: string | null | undefined;
spaceAvatar: string | null | undefined;
};
}
export type UnifiedAppNotification = SystemNotification | EntityCommentNotification | CommentReplyNotification | EntityMentionNotification | CommentMentionNotification | EntityUpvoteNotification | CommentUpvoteNotification | EntityReactionNotification | CommentReactionNotification | EntityReactionMilestoneSpecificNotification | EntityReactionMilestoneTotalNotification | CommentReactionMilestoneSpecificNotification | CommentReactionMilestoneTotalNotification | NewFollowNotification | ConnectionRequestNotification | ConnectionAcceptedNotification | SpaceMembershipApprovedNotification;
export interface EntityCommentTemplateVars {
initiatorName: string;
initiatorUsername: string;
entityTitle: string;
entityContent: string;
commentContent: string;
}
export interface CommentReplyTemplateVars {
initiatorName: string;
initiatorUsername: string;
entityTitle: string;
entityContent: string;
commentContent: string;
replyContent: string;
}
export interface EntityMentionTemplateVars {
initiatorName: string;
initiatorUsername: string;
entityTitle: string;
entityContent: string;
}
export interface CommentMentionTemplateVars {
initiatorName: string;
initiatorUsername: string;
entityTitle: string;
entityContent: string;
commentContent: string;
}
export interface EntityUpvoteTemplateVars {
initiatorName: string;
initiatorUsername: string;
entityTitle: string;
entityContent: string;
}
export interface CommentUpvoteTemplateVars {
initiatorName: string;
initiatorUsername: string;
entityTitle: string;
entityContent: string;
commentContent: string;
}
export interface EntityReactionTemplateVars {
initiatorName: string;
initiatorUsername: string;
entityTitle: string;
entityContent: string;
reactionType: string;
}
export interface CommentReactionTemplateVars {
initiatorName: string;
initiatorUsername: string;
entityTitle: string;
entityContent: string;
commentContent: string;
reactionType: string;
}
export interface EntityReactionMilestoneSpecificTemplateVars {
entityTitle: string;
entityContent: string;
reactionType: string;
milestoneCount: string;
}
export interface EntityReactionMilestoneTotalTemplateVars {
entityTitle: string;
entityContent: string;
milestoneCount: string;
}
export interface CommentReactionMilestoneSpecificTemplateVars {
entityTitle: string;
entityContent: string;
commentContent: string;
reactionType: string;
milestoneCount: string;
}
export interface CommentReactionMilestoneTotalTemplateVars {
entityTitle: string;
entityContent: string;
commentContent: string;
milestoneCount: string;
}
export interface NewFollowTemplateVars {
initiatorName: string;
initiatorUsername: string;
}
export interface ConnectionRequestTemplateVars {
initiatorName: string;
initiatorUsername: string;
}
export interface ConnectionAcceptedTemplateVars {
initiatorName: string;
initiatorUsername: string;
}
export interface SpaceMembershipApprovedTemplateVars {
spaceName: string;
spaceShortId: string;
spaceSlug: string;
}
export type TemplateField<TVars> = string | ((vars: TVars) => string);
export interface TypedNotificationTemplate<TVars> {
title?: TemplateField<TVars>;
content?: TemplateField<TVars>;
}
export type NotificationTemplates = {
entityComment: TypedNotificationTemplate<EntityCommentTemplateVars>;
commentReply: TypedNotificationTemplate<CommentReplyTemplateVars>;
entityMention: TypedNotificationTemplate<EntityMentionTemplateVars>;
commentMention: TypedNotificationTemplate<CommentMentionTemplateVars>;
entityUpvote: TypedNotificationTemplate<EntityUpvoteTemplateVars>;
commentUpvote: TypedNotificationTemplate<CommentUpvoteTemplateVars>;
entityReaction: TypedNotificationTemplate<EntityReactionTemplateVars>;
commentReaction: TypedNotificationTemplate<CommentReactionTemplateVars>;
entityReactionMilestoneSpecific: TypedNotificationTemplate<EntityReactionMilestoneSpecificTemplateVars>;
entityReactionMilestoneTotal: TypedNotificationTemplate<EntityReactionMilestoneTotalTemplateVars>;
commentReactionMilestoneSpecific: TypedNotificationTemplate<CommentReactionMilestoneSpecificTemplateVars>;
commentReactionMilestoneTotal: TypedNotificationTemplate<CommentReactionMilestoneTotalTemplateVars>;
newFollow: TypedNotificationTemplate<NewFollowTemplateVars>;
connectionRequest: TypedNotificationTemplate<ConnectionRequestTemplateVars>;
connectionAccepted: TypedNotificationTemplate<ConnectionAcceptedTemplateVars>;
spaceMembershipApproved: TypedNotificationTemplate<SpaceMembershipApprovedTemplateVars>;
};
export type PotentiallyPopulatedUnifiedAppNotification = UnifiedAppNotification & {
title?: string;
content?: string;
};
export {};