@replyke/core
Version:
Replyke: Build interactive apps with social features like comments, votes, feeds, user lists, notifications, and more.
1,085 lines (1,084 loc) • 291 kB
TypeScript
import { PayloadAction } from "@reduxjs/toolkit";
import type { ReplykeState } from '../replykeReducers';
import { Entity, EntityIncludeParam } from "../../interfaces/models/Entity";
import { EntityListSortByOptions, SortByReaction, SortDirection, SortType } from "../../interfaces/EntityListSortByOptions";
import { LocationFilters } from "../../interfaces/entity-filters/LocationFilters";
import { TimeFrame } from "../../interfaces/TimeFrame";
import { MetadataFilters } from "../../interfaces/entity-filters/MetadataFilters";
import { TitleFilters } from "../../interfaces/entity-filters/TitleFilters";
import { ContentFilters } from "../../interfaces/entity-filters/ContentFilters";
import { AttachmentsFilters } from "../../interfaces/entity-filters/AttachmentsFilters";
import { KeywordsFilters } from "../../interfaces/entity-filters/KeywordsFilters";
export interface EntityListState {
entities: Entity[];
page: number;
loading: boolean;
hasMore: boolean;
error: string | null;
lastFetched: number | null;
sourceId: string | null;
spaceId: string | null;
limit: number;
include: EntityIncludeParam | null;
sortBy: EntityListSortByOptions;
sortByReaction: SortByReaction;
sortDir: SortDirection | null;
sortType: SortType;
timeFrame: TimeFrame | null;
userId: string | null;
followedOnly: boolean;
keywordsFilters: KeywordsFilters | null;
titleFilters: TitleFilters | null;
contentFilters: ContentFilters | null;
attachmentsFilters: AttachmentsFilters | null;
locationFilters: LocationFilters | null;
metadataFilters: MetadataFilters | null;
}
export interface EntityListsState {
lists: {
[listId: string]: EntityListState;
};
}
export interface EntityListSort {
sortBy: EntityListSortByOptions;
sortByReaction?: SortByReaction;
sortDir?: SortDirection | null;
sortType?: SortType;
}
export interface EntityListFilters {
timeFrame?: TimeFrame | null;
userId?: string | null;
followedOnly?: boolean;
keywordsFilters?: KeywordsFilters | null;
titleFilters?: TitleFilters | null;
contentFilters?: ContentFilters | null;
attachmentsFilters?: AttachmentsFilters | null;
locationFilters?: LocationFilters | null;
metadataFilters?: MetadataFilters | null;
}
export interface EntityListConfig {
sourceId?: string | null;
spaceId?: string | null;
limit?: number;
include?: EntityIncludeParam | null;
}
export interface EntityListFetchOptions {
resetFilters?: boolean;
resetSort?: boolean;
fetchImmediately?: boolean;
clearImmediately?: boolean;
}
export interface FilterUpdatePayload {
listId: string;
filters: Partial<EntityListFilters>;
sort?: Partial<EntityListSort>;
config?: EntityListConfig;
options?: EntityListFetchOptions;
}
export interface InitializeListPayload {
listId: string;
}
export interface KeywordsUpdatePayload {
listId: string;
type: "add" | "remove" | "reset" | "replace";
key: "includes" | "doesNotInclude" | "both";
value?: string | string[];
}
export interface EntityAddPayload {
listId: string;
entity: Entity;
insertPosition?: "first" | "last";
}
export interface EntityRemovePayload {
listId: string;
entityId: string;
}
export interface EntitiesSetPayload {
listId: string;
entities: Entity[];
append?: boolean;
}
export declare const entityListsSlice: import("@reduxjs/toolkit").Slice<EntityListsState, {
initializeList: (state: {
lists: {
[x: string]: {
entities: {
id: string;
foreignId: string | null;
shortId: string;
projectId: string;
sourceId: string | null;
spaceId: string | null;
space?: {
id: string;
projectId: string;
shortId: string;
slug: string | null;
name: string;
description: string | null;
avatarFileId: string | null;
bannerFileId: string | null;
userId: string;
readingPermission: import("../..").ReadingPermission;
postingPermission: import("../..").PostingPermission;
requireJoinApproval: boolean;
parentSpaceId: string | null;
depth: number;
metadata: {
[x: string]: any;
};
createdAt: Date;
updatedAt: Date;
deletedAt: Date | null;
membersCount: number;
childSpacesCount: number;
isMember?: boolean | undefined;
avatarFile?: {
id: string;
projectId: string;
userId: string | null;
entityId: string | null;
commentId: string | null;
chatMessageId: string | null;
spaceId: string | null;
type: "image" | "video" | "document" | "other";
originalPath: string;
originalSize: number;
originalMimeType: string;
position: number;
metadata: {
[x: string]: any;
};
image?: {
fileId: string;
originalWidth: number;
originalHeight: number;
variants: {
[x: string]: {
path: string;
publicPath: string;
width: number;
height: number;
size: number;
format: string;
};
};
processingStatus: "completed" | "failed";
processingError: string | null;
format: string;
quality: number;
exifStripped: boolean;
createdAt: Date;
updatedAt: Date;
} | undefined;
createdAt: Date;
updatedAt: Date;
} | undefined;
bannerFile?: {
id: string;
projectId: string;
userId: string | null;
entityId: string | null;
commentId: string | null;
chatMessageId: string | null;
spaceId: string | null;
type: "image" | "video" | "document" | "other";
originalPath: string;
originalSize: number;
originalMimeType: string;
position: number;
metadata: {
[x: string]: any;
};
image?: {
fileId: string;
originalWidth: number;
originalHeight: number;
variants: {
[x: string]: {
path: string;
publicPath: string;
width: number;
height: number;
size: number;
format: string;
};
};
processingStatus: "completed" | "failed";
processingError: string | null;
format: string;
quality: number;
exifStripped: boolean;
createdAt: Date;
updatedAt: Date;
} | undefined;
createdAt: Date;
updatedAt: Date;
} | undefined;
} | null | undefined;
userId: string | null;
user?: {
id: string;
projectId: string;
foreignId: string | null;
role: import("../..").UserRole;
name: string | null;
username: string | null;
avatar: string | null;
avatarFileId: string | null;
bannerFileId: string | null;
avatarFile?: {
id: string;
projectId: string;
userId: string | null;
entityId: string | null;
commentId: string | null;
chatMessageId: string | null;
spaceId: string | null;
type: "image" | "video" | "document" | "other";
originalPath: string;
originalSize: number;
originalMimeType: string;
position: number;
metadata: {
[x: string]: any;
};
image?: {
fileId: string;
originalWidth: number;
originalHeight: number;
variants: {
[x: string]: {
path: string;
publicPath: string;
width: number;
height: number;
size: number;
format: string;
};
};
processingStatus: "completed" | "failed";
processingError: string | null;
format: string;
quality: number;
exifStripped: boolean;
createdAt: Date;
updatedAt: Date;
} | undefined;
createdAt: Date;
updatedAt: Date;
} | null | undefined;
bannerFile?: {
id: string;
projectId: string;
userId: string | null;
entityId: string | null;
commentId: string | null;
chatMessageId: string | null;
spaceId: string | null;
type: "image" | "video" | "document" | "other";
originalPath: string;
originalSize: number;
originalMimeType: string;
position: number;
metadata: {
[x: string]: any;
};
image?: {
fileId: string;
originalWidth: number;
originalHeight: number;
variants: {
[x: string]: {
path: string;
publicPath: string;
width: number;
height: number;
size: number;
format: string;
};
};
processingStatus: "completed" | "failed";
processingError: string | null;
format: string;
quality: number;
exifStripped: boolean;
createdAt: Date;
updatedAt: Date;
} | undefined;
createdAt: Date;
updatedAt: Date;
} | null | undefined;
bio: string | null;
birthdate: Date | null;
location: {
type: "Point";
coordinates: [number, number];
} | null;
metadata: {
[x: string]: any;
};
reputation: number;
createdAt: Date;
} | null | undefined;
title: string | null;
content: string | null;
mentions: ({
type: "user";
id: string;
foreignId?: string | null | undefined;
username: string;
} | {
type: "space";
id: string;
slug: string;
})[];
attachments: {
[x: string]: any;
}[];
files?: {
id: string;
projectId: string;
userId: string | null;
entityId: string | null;
commentId: string | null;
chatMessageId: string | null;
spaceId: string | null;
type: "image" | "video" | "document" | "other";
originalPath: string;
originalSize: number;
originalMimeType: string;
position: number;
metadata: {
[x: string]: any;
};
image?: {
fileId: string;
originalWidth: number;
originalHeight: number;
variants: {
[x: string]: {
path: string;
publicPath: string;
width: number;
height: number;
size: number;
format: string;
};
};
processingStatus: "completed" | "failed";
processingError: string | null;
format: string;
quality: number;
exifStripped: boolean;
createdAt: Date;
updatedAt: Date;
} | undefined;
createdAt: Date;
updatedAt: Date;
}[] | undefined;
keywords: string[];
upvotes: string[];
downvotes: string[];
reactionCounts: {
upvote: number;
downvote: number;
like: number;
love: number;
wow: number;
sad: number;
angry: number;
funny: number;
};
userReaction?: (import("../..").ReactionType | null) | undefined;
repliesCount: number;
views: number;
score: number;
scoreUpdatedAt: Date;
location: {
type: "Point";
coordinates: [number, number];
} | null;
metadata: {
[x: string]: any;
};
topComment: {
id: string;
user: {
id: string;
projectId: string;
foreignId: string | null;
role: import("../..").UserRole;
name: string | null;
username: string | null;
avatar: string | null;
avatarFileId: string | null;
bannerFileId: string | null;
avatarFile?: {
id: string;
projectId: string;
userId: string | null;
entityId: string | null;
commentId: string | null;
chatMessageId: string | null;
spaceId: string | null;
type: "image" | "video" | "document" | "other";
originalPath: string;
originalSize: number;
originalMimeType: string;
position: number;
metadata: {
[x: string]: any;
};
image?: {
fileId: string;
originalWidth: number;
originalHeight: number;
variants: {
[x: string]: {
path: string;
publicPath: string;
width: number;
height: number;
size: number;
format: string;
};
};
processingStatus: "completed" | "failed";
processingError: string | null;
format: string;
quality: number;
exifStripped: boolean;
createdAt: Date;
updatedAt: Date;
} | undefined;
createdAt: Date;
updatedAt: Date;
} | null | undefined;
bannerFile?: {
id: string;
projectId: string;
userId: string | null;
entityId: string | null;
commentId: string | null;
chatMessageId: string | null;
spaceId: string | null;
type: "image" | "video" | "document" | "other";
originalPath: string;
originalSize: number;
originalMimeType: string;
position: number;
metadata: {
[x: string]: any;
};
image?: {
fileId: string;
originalWidth: number;
originalHeight: number;
variants: {
[x: string]: {
path: string;
publicPath: string;
width: number;
height: number;
size: number;
format: string;
};
};
processingStatus: "completed" | "failed";
processingError: string | null;
format: string;
quality: number;
exifStripped: boolean;
createdAt: Date;
updatedAt: Date;
} | undefined;
createdAt: Date;
updatedAt: Date;
} | null | undefined;
bio: string | null;
birthdate: Date | null;
location: {
type: "Point";
coordinates: [number, number];
} | null;
metadata: {
[x: string]: any;
};
reputation: number;
createdAt: Date;
};
upvotesCount: number;
content: string;
createdAt: string;
} | null;
isSaved?: boolean | undefined;
createdAt: Date;
updatedAt: Date;
deletedAt: Date | null;
isDraft: boolean | null;
moderationStatus: "approved" | "removed" | null;
moderatedAt: Date | null;
moderatedById: string | null;
moderatedByType: "client" | "user" | null;
moderationReason: string | null;
}[];
page: number;
loading: boolean;
hasMore: boolean;
error: string | null;
lastFetched: number | null;
sourceId: string | null;
spaceId: string | null;
limit: number;
include: string | import("../../interfaces/models/Entity").EntityInclude[] | null;
sortBy: EntityListSortByOptions;
sortByReaction: SortByReaction;
sortDir: SortDirection | null;
sortType: SortType;
timeFrame: TimeFrame | null;
userId: string | null;
followedOnly: boolean;
keywordsFilters: {
includes?: string[] | undefined;
doesNotInclude?: string[] | undefined;
} | null;
titleFilters: {
hasTitle?: boolean | undefined;
includes?: string | string[] | undefined;
doesNotInclude?: string | string[] | undefined;
} | null;
contentFilters: {
hasContent?: boolean | undefined;
includes?: string | string[] | undefined;
doesNotInclude?: string | string[] | undefined;
} | null;
attachmentsFilters: {
hasAttachments?: boolean | undefined;
} | null;
locationFilters: {
latitude: number;
longitude: number;
radius: number;
} | null;
metadataFilters: {
includes?: {
[x: string]: unknown;
} | undefined;
includesAny?: {
[x: string]: unknown;
}[] | undefined;
doesNotInclude?: {
[x: string]: unknown;
} | undefined;
exists?: string[] | undefined;
doesNotExist?: string[] | undefined;
} | null;
};
};
}, action: PayloadAction<InitializeListPayload>) => void;
updateFiltersAndSortConfig: (state: {
lists: {
[x: string]: {
entities: {
id: string;
foreignId: string | null;
shortId: string;
projectId: string;
sourceId: string | null;
spaceId: string | null;
space?: {
id: string;
projectId: string;
shortId: string;
slug: string | null;
name: string;
description: string | null;
avatarFileId: string | null;
bannerFileId: string | null;
userId: string;
readingPermission: import("../..").ReadingPermission;
postingPermission: import("../..").PostingPermission;
requireJoinApproval: boolean;
parentSpaceId: string | null;
depth: number;
metadata: {
[x: string]: any;
};
createdAt: Date;
updatedAt: Date;
deletedAt: Date | null;
membersCount: number;
childSpacesCount: number;
isMember?: boolean | undefined;
avatarFile?: {
id: string;
projectId: string;
userId: string | null;
entityId: string | null;
commentId: string | null;
chatMessageId: string | null;
spaceId: string | null;
type: "image" | "video" | "document" | "other";
originalPath: string;
originalSize: number;
originalMimeType: string;
position: number;
metadata: {
[x: string]: any;
};
image?: {
fileId: string;
originalWidth: number;
originalHeight: number;
variants: {
[x: string]: {
path: string;
publicPath: string;
width: number;
height: number;
size: number;
format: string;
};
};
processingStatus: "completed" | "failed";
processingError: string | null;
format: string;
quality: number;
exifStripped: boolean;
createdAt: Date;
updatedAt: Date;
} | undefined;
createdAt: Date;
updatedAt: Date;
} | undefined;
bannerFile?: {
id: string;
projectId: string;
userId: string | null;
entityId: string | null;
commentId: string | null;
chatMessageId: string | null;
spaceId: string | null;
type: "image" | "video" | "document" | "other";
originalPath: string;
originalSize: number;
originalMimeType: string;
position: number;
metadata: {
[x: string]: any;
};
image?: {
fileId: string;
originalWidth: number;
originalHeight: number;
variants: {
[x: string]: {
path: string;
publicPath: string;
width: number;
height: number;
size: number;
format: string;
};
};
processingStatus: "completed" | "failed";
processingError: string | null;
format: string;
quality: number;
exifStripped: boolean;
createdAt: Date;
updatedAt: Date;
} | undefined;
createdAt: Date;
updatedAt: Date;
} | undefined;
} | null | undefined;
userId: string | null;
user?: {
id: string;
projectId: string;
foreignId: string | null;
role: import("../..").UserRole;
name: string | null;
username: string | null;
avatar: string | null;
avatarFileId: string | null;
bannerFileId: string | null;
avatarFile?: {
id: string;
projectId: string;
userId: string | null;
entityId: string | null;
commentId: string | null;
chatMessageId: string | null;
spaceId: string | null;
type: "image" | "video" | "document" | "other";
originalPath: string;
originalSize: number;
originalMimeType: string;
position: number;
metadata: {
[x: string]: any;
};
image?: {
fileId: string;
originalWidth: number;
originalHeight: number;
variants: {
[x: string]: {
path: string;
publicPath: string;
width: number;
height: number;
size: number;
format: string;
};
};
processingStatus: "completed" | "failed";
processingError: string | null;
format: string;
quality: number;
exifStripped: boolean;
createdAt: Date;
updatedAt: Date;
} | undefined;
createdAt: Date;
updatedAt: Date;
} | null | undefined;
bannerFile?: {
id: string;
projectId: string;
userId: string | null;
entityId: string | null;
commentId: string | null;
chatMessageId: string | null;
spaceId: string | null;
type: "image" | "video" | "document" | "other";
originalPath: string;
originalSize: number;
originalMimeType: string;
position: number;
metadata: {
[x: string]: any;
};
image?: {
fileId: string;
originalWidth: number;
originalHeight: number;
variants: {
[x: string]: {
path: string;
publicPath: string;
width: number;
height: number;
size: number;
format: string;
};
};
processingStatus: "completed" | "failed";
processingError: string | null;
format: string;
quality: number;
exifStripped: boolean;
createdAt: Date;
updatedAt: Date;
} | undefined;
createdAt: Date;
updatedAt: Date;
} | null | undefined;
bio: string | null;
birthdate: Date | null;
location: {
type: "Point";
coordinates: [number, number];
} | null;
metadata: {
[x: string]: any;
};
reputation: number;
createdAt: Date;
} | null | undefined;
title: string | null;
content: string | null;
mentions: ({
type: "user";
id: string;
foreignId?: string | null | undefined;
username: string;
} | {
type: "space";
id: string;
slug: string;
})[];
attachments: {
[x: string]: any;
}[];
files?: {
id: string;
projectId: string;
userId: string | null;
entityId: string | null;
commentId: string | null;
chatMessageId: string | null;
spaceId: string | null;
type: "image" | "video" | "document" | "other";
originalPath: string;
originalSize: number;
originalMimeType: string;
position: number;
metadata: {
[x: string]: any;
};
image?: {
fileId: string;
originalWidth: number;
originalHeight: number;
variants: {
[x: string]: {
path: string;
publicPath: string;
width: number;
height: number;
size: number;
format: string;
};
};
processingStatus: "completed" | "failed";
processingError: string | null;
format: string;
quality: number;
exifStripped: boolean;
createdAt: Date;
updatedAt: Date;
} | undefined;
createdAt: Date;
updatedAt: Date;
}[] | undefined;
keywords: string[];
upvotes: string[];
downvotes: string[];
reactionCounts: {
upvote: number;
downvote: number;
like: number;
love: number;
wow: number;
sad: number;
angry: number;
funny: number;
};
userReaction?: (import("../..").ReactionType | null) | undefined;
repliesCount: number;
views: number;
score: number;
scoreUpdatedAt: Date;
location: {
type: "Point";
coordinates: [number, number];
} | null;
metadata: {
[x: string]: any;
};
topComment: {
id: string;
user: {
id: string;
projectId: string;
foreignId: string | null;
role: import("../..").UserRole;
name: string | null;
username: string | null;
avatar: string | null;
avatarFileId: string | null;
bannerFileId: string | null;
avatarFile?: {
id: string;
projectId: string;
userId: string | null;
entityId: string | null;
commentId: string | null;
chatMessageId: string | null;
spaceId: string | null;
type: "image" | "video" | "document" | "other";
originalPath: string;
originalSize: number;
originalMimeType: string;
position: number;
metadata: {
[x: string]: any;
};
image?: {
fileId: string;
originalWidth: number;
originalHeight: number;
variants: {
[x: string]: {
path: string;
publicPath: string;
width: number;
height: number;
size: number;
format: string;
};
};
processingStatus: "completed" | "failed";
processingError: string | null;
format: string;
quality: number;
exifStripped: boolean;
createdAt: Date;
updatedAt: Date;
} | undefined;
createdAt: Date;
updatedAt: Date;
} | null | undefined;
bannerFile?: {
id: string;
projectId: string;
userId: string | null;
entityId: string | null;
commentId: string | null;
chatMessageId: string | null;
spaceId: string | null;
type: "image" | "video" | "document" | "other";
originalPath: string;
originalSize: number;
originalMimeType: string;
position: number;
metadata: {
[x: string]: any;
};
image?: {
fileId: string;
originalWidth: number;
originalHeight: number;
variants: {
[x: string]: {
path: string;
publicPath: string;
width: number;
height: number;
size: number;
format: string;
};
};
processingStatus: "completed" | "failed";
processingError: string | null;
format: string;
quality: number;
exifStripped: boolean;
createdAt: Date;
updatedAt: Date;
} | undefined;
createdAt: Date;
updatedAt: Date;
} | null | undefined;
bio: string | null;
birthdate: Date | null;
location: {
type: "Point";
coordinates: [number, number];
} | null;
metadata: {
[x: string]: any;
};
reputation: number;
createdAt: Date;
};
upvotesCount: number;
content: string;
createdAt: string;
} | null;
isSaved?: boolean | undefined;
createdAt: Date;
updatedAt: Date;
deletedAt: Date | null;
isDraft: boolean | null;
moderationStatus: "approved" | "removed" | null;
moderatedAt: Date | null;
moderatedById: string | null;
moderatedByType: "client" | "user" | null;
moderationReason: string | null;
}[];
page: number;
loading: boolean;
hasMore: boolean;
error: string | null;
lastFetched: number | null;
sourceId: string | null;
spaceId: string | null;
limit: number;
include: string | import("../../interfaces/models/Entity").EntityInclude[] | null;
sortBy: EntityListSortByOptions;
sortByReaction: SortByReaction;
sortDir: SortDirection | null;
sortType: SortType;
timeFrame: TimeFrame | null;
userId: string | null;
followedOnly: boolean;
keywordsFilters: {
includes?: string[] | undefined;
doesNotInclude?: string[] | undefined;
} | null;
titleFilters: {
hasTitle?: boolean | undefined;
includes?: string | string[] | undefined;
doesNotInclude?: string | string[] | undefined;
} | null;
contentFilters: {
hasContent?: boolean | undefined;
includes?: string | string[] | undefined;
doesNotInclude?: string | string[] | undefined;
} | null;
attachmentsFilters: {
hasAttachments?: boolean | undefined;
} | null;
locationFilters: {
latitude: number;
longitude: number;
radius: number;
} | null;
metadataFilters: {
includes?: {
[x: string]: unknown;
} | undefined;
includesAny?: {
[x: string]: unknown;
}[] | undefined;
doesNotInclude?: {
[x: string]: unknown;
} | undefined;
exists?: string[] | undefined;
doesNotExist?: string[] | undefined;
} | null;
};
};
}, action: PayloadAction<FilterUpdatePayload>) => void;
setEntityListLoading: (state: {
lists: {
[x: string]: {
entities: {
id: string;
foreignId: string | null;
shortId: string;
projectId: string;
sourceId: string | null;
spaceId: string | null;
space?: {
id: string;
projectId: string;
shortId: string;
slug: string | null;
name: string;
description: string | null;
avatarFileId: string | null;
bannerFileId: string | null;
userId: string;
readingPermission: import("../..").ReadingPermission;
postingPermission: import("../..").PostingPermission;
requireJoinApproval: boolean;
parentSpaceId: string | null;
depth: number;
metadata: {
[x: string]: any;