strapi-plugin-comments
Version:
971 lines (970 loc) • 32.7 kB
TypeScript
import { RequestContext, StrapiContext } from '../@types';
import { PluginServices } from '../services';
import { client as clientValidator } from '../validators/api';
declare const controllers: ({ strapi }: StrapiContext) => {
getService<T extends "gql" | "client" | "admin" | "common" | "settings">(name: T): PluginServices[T];
getStoreRepository(): {
getLocalConfig<P extends string>(prop?: P, defaultValue?: import("../@types").PathValue<{
enabledCollections?: string[];
approvalFlow?: string[];
entryLabel?: Record<string, string[]>;
moderatorRoles?: string[];
badWords?: boolean;
blockedAuthorProps?: string[];
isValidationEnabled?: boolean;
reportReasons?: {
BAD_LANGUAGE?: import("../const").REPORT_REASON.BAD_LANGUAGE;
DISCRIMINATION?: import("../const").REPORT_REASON.DISCRIMINATION;
OTHER?: import("../const").REPORT_REASON.OTHER;
};
isGQLPluginEnabled?: boolean;
gql?: {
auth?: boolean;
};
client?: {
url?: string;
contactEmail?: string;
};
}, P>): import("../@types").PathValue<{
enabledCollections?: string[];
approvalFlow?: string[];
entryLabel?: Record<string, string[]>;
moderatorRoles?: string[];
badWords?: boolean;
blockedAuthorProps?: string[];
isValidationEnabled?: boolean;
reportReasons?: {
BAD_LANGUAGE?: import("../const").REPORT_REASON.BAD_LANGUAGE;
DISCRIMINATION?: import("../const").REPORT_REASON.DISCRIMINATION;
OTHER?: import("../const").REPORT_REASON.OTHER;
};
isGQLPluginEnabled?: boolean;
gql?: {
auth?: boolean;
};
client?: {
url?: string;
contactEmail?: string;
};
}, P>;
getStore(): Promise<{
get(params?: Partial<{
key: string;
type?: string;
environment?: string;
name?: string;
tag?: string;
}>): Promise<unknown>;
set(params?: Partial<{
key: string;
value: unknown;
type?: string;
environment?: string;
name?: string;
tag?: string;
}>): Promise<void>;
delete(params?: Partial<{
key: string;
type?: string;
environment?: string;
name?: string;
tag?: string;
}>): Promise<void>;
}>;
getConfig(): Promise<Required<{
enabledCollections?: string[];
approvalFlow?: string[];
entryLabel?: Record<string, string[]>;
moderatorRoles?: string[];
badWords?: boolean;
blockedAuthorProps?: string[];
isValidationEnabled?: boolean;
reportReasons?: {
BAD_LANGUAGE?: import("../const").REPORT_REASON.BAD_LANGUAGE;
DISCRIMINATION?: import("../const").REPORT_REASON.DISCRIMINATION;
OTHER?: import("../const").REPORT_REASON.OTHER;
};
isGQLPluginEnabled?: boolean;
gql?: {
auth?: boolean;
};
client?: {
url?: string;
contactEmail?: string;
};
}>>;
get<T_1 extends boolean>(viaSettingsPage?: T_1): Promise<import("../utils/Either").Either<unknown, T_1 extends true ? {
enabledCollections?: string[];
approvalFlow?: string[];
entryLabel?: Record<string, string[]>;
moderatorRoles?: string[];
badWords?: boolean;
blockedAuthorProps?: string[];
isValidationEnabled?: boolean;
reportReasons?: {
BAD_LANGUAGE?: import("../const").REPORT_REASON.BAD_LANGUAGE;
DISCRIMINATION?: import("../const").REPORT_REASON.DISCRIMINATION;
OTHER?: import("../const").REPORT_REASON.OTHER;
};
isGQLPluginEnabled?: boolean;
gql?: {
auth?: boolean;
};
client?: {
url?: string;
contactEmail?: string;
};
} : Omit<{
enabledCollections?: string[];
approvalFlow?: string[];
entryLabel?: Record<string, string[]>;
moderatorRoles?: string[];
badWords?: boolean;
blockedAuthorProps?: string[];
isValidationEnabled?: boolean;
reportReasons?: {
BAD_LANGUAGE?: import("../const").REPORT_REASON.BAD_LANGUAGE;
DISCRIMINATION?: import("../const").REPORT_REASON.DISCRIMINATION;
OTHER?: import("../const").REPORT_REASON.OTHER;
};
isGQLPluginEnabled?: boolean;
gql?: {
auth?: boolean;
};
client?: {
url?: string;
contactEmail?: string;
};
}, "enabledCollections" | "moderatorRoles" | "isGQLPluginEnabled">>>;
update(config: {
enabledCollections?: string[];
approvalFlow?: string[];
entryLabel?: Record<string, string[]>;
moderatorRoles?: string[];
badWords?: boolean;
blockedAuthorProps?: string[];
isValidationEnabled?: boolean;
reportReasons?: {
BAD_LANGUAGE?: import("../const").REPORT_REASON.BAD_LANGUAGE;
DISCRIMINATION?: import("../const").REPORT_REASON.DISCRIMINATION;
OTHER?: import("../const").REPORT_REASON.OTHER;
};
isGQLPluginEnabled?: boolean;
gql?: {
auth?: boolean;
};
client?: {
url?: string;
contactEmail?: string;
};
}): Promise<import("../utils/Either").Either<unknown, {
enabledCollections?: string[];
approvalFlow?: string[];
entryLabel?: Record<string, string[]>;
moderatorRoles?: string[];
badWords?: boolean;
blockedAuthorProps?: string[];
isValidationEnabled?: boolean;
reportReasons?: {
BAD_LANGUAGE?: import("../const").REPORT_REASON.BAD_LANGUAGE;
DISCRIMINATION?: import("../const").REPORT_REASON.DISCRIMINATION;
OTHER?: import("../const").REPORT_REASON.OTHER;
};
isGQLPluginEnabled?: boolean;
gql?: {
auth?: boolean;
};
client?: {
url?: string;
contactEmail?: string;
};
} | Omit<{
enabledCollections?: string[];
approvalFlow?: string[];
entryLabel?: Record<string, string[]>;
moderatorRoles?: string[];
badWords?: boolean;
blockedAuthorProps?: string[];
isValidationEnabled?: boolean;
reportReasons?: {
BAD_LANGUAGE?: import("../const").REPORT_REASON.BAD_LANGUAGE;
DISCRIMINATION?: import("../const").REPORT_REASON.DISCRIMINATION;
OTHER?: import("../const").REPORT_REASON.OTHER;
};
isGQLPluginEnabled?: boolean;
gql?: {
auth?: boolean;
};
client?: {
url?: string;
contactEmail?: string;
};
}, "enabledCollections" | "moderatorRoles" | "isGQLPluginEnabled">>>;
restore(): Promise<import("../utils/Either").Either<unknown, {
enabledCollections?: string[];
approvalFlow?: string[];
entryLabel?: Record<string, string[]>;
moderatorRoles?: string[];
badWords?: boolean;
blockedAuthorProps?: string[];
isValidationEnabled?: boolean;
reportReasons?: {
BAD_LANGUAGE?: import("../const").REPORT_REASON.BAD_LANGUAGE;
DISCRIMINATION?: import("../const").REPORT_REASON.DISCRIMINATION;
OTHER?: import("../const").REPORT_REASON.OTHER;
};
isGQLPluginEnabled?: boolean;
gql?: {
auth?: boolean;
};
client?: {
url?: string;
contactEmail?: string;
};
} | Omit<{
enabledCollections?: string[];
approvalFlow?: string[];
entryLabel?: Record<string, string[]>;
moderatorRoles?: string[];
badWords?: boolean;
blockedAuthorProps?: string[];
isValidationEnabled?: boolean;
reportReasons?: {
BAD_LANGUAGE?: import("../const").REPORT_REASON.BAD_LANGUAGE;
DISCRIMINATION?: import("../const").REPORT_REASON.DISCRIMINATION;
OTHER?: import("../const").REPORT_REASON.OTHER;
};
isGQLPluginEnabled?: boolean;
gql?: {
auth?: boolean;
};
client?: {
url?: string;
contactEmail?: string;
};
}, "enabledCollections" | "moderatorRoles" | "isGQLPluginEnabled">>>;
};
post(ctx: RequestContext<object, Pick<clientValidator.NewCommentValidatorSchema, 'relation'>>): Promise<{
id?: number;
documentId?: string;
content?: string;
blocked?: boolean;
blockedThread?: boolean;
blockReason?: string;
isAdminComment?: boolean;
removed?: boolean;
approvalStatus?: string;
related?: string;
createdAt?: string;
updatedAt?: string;
publishedAt?: string;
authorId?: string;
authorName?: string;
authorEmail?: string;
authorAvatar?: string;
authorUser?: string | {
id?: number;
email?: string;
};
locale?: string;
gotThread?: boolean;
threadFirstItemId?: number;
reports?: {
id?: number;
documentId?: string;
content?: string;
createdAt?: string;
updatedAt?: string;
publishedAt?: string;
locale?: string;
reason?: string;
resolved?: boolean;
}[];
author?: any;
threadOf?: number | {
id?: number;
documentId?: string;
content?: string;
blocked?: boolean;
blockedThread?: boolean;
blockReason?: string;
isAdminComment?: boolean;
removed?: boolean;
approvalStatus?: string;
related?: string;
createdAt?: string;
updatedAt?: string;
publishedAt?: string;
authorId?: string;
authorName?: string;
authorEmail?: string;
authorAvatar?: string;
authorUser?: string | {
id?: number;
email?: string;
};
locale?: string;
gotThread?: boolean;
threadFirstItemId?: number;
reports?: {
id?: number;
documentId?: string;
content?: string;
createdAt?: string;
updatedAt?: string;
publishedAt?: string;
locale?: string;
reason?: string;
resolved?: boolean;
}[];
author?: any;
};
}>;
findAllFlat(ctx: RequestContext<object, Pick<clientValidator.FindAllFlatSchema, 'relation'>>): Promise<{
data: ({
id?: number;
documentId?: string;
content?: string;
blocked?: boolean;
blockedThread?: boolean;
blockReason?: string;
isAdminComment?: boolean;
removed?: boolean;
approvalStatus?: string;
related?: string;
createdAt?: string;
updatedAt?: string;
publishedAt?: string;
authorId?: string;
authorName?: string;
authorEmail?: string;
authorAvatar?: string;
authorUser?: string | {
id?: number;
email?: string;
};
locale?: string;
gotThread?: boolean;
threadFirstItemId?: number;
reports?: {
id?: number;
documentId?: string;
content?: string;
createdAt?: string;
updatedAt?: string;
publishedAt?: string;
locale?: string;
reason?: string;
resolved?: boolean;
}[];
author?: any;
threadOf?: number | {
id?: number;
documentId?: string;
content?: string;
blocked?: boolean;
blockedThread?: boolean;
blockReason?: string;
isAdminComment?: boolean;
removed?: boolean;
approvalStatus?: string;
related?: string;
createdAt?: string;
updatedAt?: string;
publishedAt?: string;
authorId?: string;
authorName?: string;
authorEmail?: string;
authorAvatar?: string;
authorUser?: string | {
id?: number;
email?: string;
};
locale?: string;
gotThread?: boolean;
threadFirstItemId?: number;
reports?: {
id?: number;
documentId?: string;
content?: string;
createdAt?: string;
updatedAt?: string;
publishedAt?: string;
locale?: string;
reason?: string;
resolved?: boolean;
}[];
author?: any;
};
} | {
id?: number;
documentId?: string;
content?: string;
blocked?: boolean;
blockedThread?: boolean;
blockReason?: string;
isAdminComment?: boolean;
removed?: boolean;
approvalStatus?: string;
related?: {
id?: number;
documentId?: string;
locale?: string;
uid?: string;
requireCommentsApproval?: boolean;
};
createdAt?: string;
updatedAt?: string;
publishedAt?: string;
authorId?: string;
authorName?: string;
authorEmail?: string;
authorAvatar?: string;
authorUser?: string | {
id?: number;
email?: string;
};
locale?: string;
gotThread?: boolean;
threadFirstItemId?: number;
reports?: {
id?: number;
documentId?: string;
content?: string;
createdAt?: string;
updatedAt?: string;
publishedAt?: string;
locale?: string;
reason?: string;
resolved?: boolean;
}[];
author?: any;
threadOf?: number | {
id?: number;
documentId?: string;
content?: string;
blocked?: boolean;
blockedThread?: boolean;
blockReason?: string;
isAdminComment?: boolean;
removed?: boolean;
approvalStatus?: string;
related?: string;
createdAt?: string;
updatedAt?: string;
publishedAt?: string;
authorId?: string;
authorName?: string;
authorEmail?: string;
authorAvatar?: string;
authorUser?: string | {
id?: number;
email?: string;
};
locale?: string;
gotThread?: boolean;
threadFirstItemId?: number;
reports?: {
id?: number;
documentId?: string;
content?: string;
createdAt?: string;
updatedAt?: string;
publishedAt?: string;
locale?: string;
reason?: string;
resolved?: boolean;
}[];
author?: any;
};
})[];
pagination?: {
page?: number;
pageSize?: number;
pageCount?: number;
total?: number;
};
}>;
findAllInHierarchy(ctx: RequestContext<object, Pick<clientValidator.FindAllInHierarchyValidatorSchema, 'relation'>>): Promise<{
id?: number;
documentId?: string;
content?: string;
blocked?: boolean;
blockedThread?: boolean;
blockReason?: string;
isAdminComment?: boolean;
removed?: boolean;
approvalStatus?: string;
related?: string;
createdAt?: string;
updatedAt?: string;
publishedAt?: string;
authorId?: string;
authorName?: string;
authorEmail?: string;
authorAvatar?: string;
authorUser?: string | {
id?: number;
email?: string;
};
locale?: string;
gotThread?: boolean;
threadFirstItemId?: number;
reports?: {
id?: number;
documentId?: string;
content?: string;
createdAt?: string;
updatedAt?: string;
publishedAt?: string;
locale?: string;
reason?: string;
resolved?: boolean;
}[];
author?: any;
threadOf?: number | {
id?: number;
documentId?: string;
content?: string;
blocked?: boolean;
blockedThread?: boolean;
blockReason?: string;
isAdminComment?: boolean;
removed?: boolean;
approvalStatus?: string;
related?: string;
createdAt?: string;
updatedAt?: string;
publishedAt?: string;
authorId?: string;
authorName?: string;
authorEmail?: string;
authorAvatar?: string;
authorUser?: string | {
id?: number;
email?: string;
};
locale?: string;
gotThread?: boolean;
threadFirstItemId?: number;
reports?: {
id?: number;
documentId?: string;
content?: string;
createdAt?: string;
updatedAt?: string;
publishedAt?: string;
locale?: string;
reason?: string;
resolved?: boolean;
}[];
author?: any;
};
}[]>;
findAllPerAuthor(ctx: RequestContext<object, Pick<clientValidator.FindAllPerAuthorValidatorSchema, 'authorId' | 'type'>>): Promise<{
data: ({
id?: number;
documentId?: string;
content?: string;
blocked?: boolean;
blockedThread?: boolean;
blockReason?: string;
isAdminComment?: boolean;
removed?: boolean;
approvalStatus?: string;
related?: string;
createdAt?: string;
updatedAt?: string;
publishedAt?: string;
authorId?: string;
authorName?: string;
authorEmail?: string;
authorAvatar?: string;
authorUser?: string | {
id?: number;
email?: string;
};
locale?: string;
gotThread?: boolean;
threadFirstItemId?: number;
reports?: {
id?: number;
documentId?: string;
content?: string;
createdAt?: string;
updatedAt?: string;
publishedAt?: string;
locale?: string;
reason?: string;
resolved?: boolean;
}[];
threadOf?: number | {
id?: number;
documentId?: string;
content?: string;
blocked?: boolean;
blockedThread?: boolean;
blockReason?: string;
isAdminComment?: boolean;
removed?: boolean;
approvalStatus?: string;
related?: string;
createdAt?: string;
updatedAt?: string;
publishedAt?: string;
authorId?: string;
authorName?: string;
authorEmail?: string;
authorAvatar?: string;
authorUser?: string | {
id?: number;
email?: string;
};
locale?: string;
gotThread?: boolean;
threadFirstItemId?: number;
reports?: {
id?: number;
documentId?: string;
content?: string;
createdAt?: string;
updatedAt?: string;
publishedAt?: string;
locale?: string;
reason?: string;
resolved?: boolean;
}[];
author?: any;
};
} | {
id?: number;
documentId?: string;
content?: string;
blocked?: boolean;
blockedThread?: boolean;
blockReason?: string;
isAdminComment?: boolean;
removed?: boolean;
approvalStatus?: string;
related?: {
id?: number;
documentId?: string;
locale?: string;
uid?: string;
requireCommentsApproval?: boolean;
};
createdAt?: string;
updatedAt?: string;
publishedAt?: string;
authorId?: string;
authorName?: string;
authorEmail?: string;
authorAvatar?: string;
authorUser?: string | {
id?: number;
email?: string;
};
locale?: string;
gotThread?: boolean;
threadFirstItemId?: number;
reports?: {
id?: number;
documentId?: string;
content?: string;
createdAt?: string;
updatedAt?: string;
publishedAt?: string;
locale?: string;
reason?: string;
resolved?: boolean;
}[];
threadOf?: number | {
id?: number;
documentId?: string;
content?: string;
blocked?: boolean;
blockedThread?: boolean;
blockReason?: string;
isAdminComment?: boolean;
removed?: boolean;
approvalStatus?: string;
related?: string;
createdAt?: string;
updatedAt?: string;
publishedAt?: string;
authorId?: string;
authorName?: string;
authorEmail?: string;
authorAvatar?: string;
authorUser?: string | {
id?: number;
email?: string;
};
locale?: string;
gotThread?: boolean;
threadFirstItemId?: number;
reports?: {
id?: number;
documentId?: string;
content?: string;
createdAt?: string;
updatedAt?: string;
publishedAt?: string;
locale?: string;
reason?: string;
resolved?: boolean;
}[];
author?: any;
};
})[];
pagination?: {
page?: number;
pageSize?: number;
pageCount?: number;
total?: number;
};
}>;
put(ctx: RequestContext<{
content: string;
author: unknown;
}>): Promise<{
id?: number;
documentId?: string;
content?: string;
blocked?: boolean;
blockedThread?: boolean;
blockReason?: string;
isAdminComment?: boolean;
removed?: boolean;
approvalStatus?: string;
related?: string;
createdAt?: string;
updatedAt?: string;
publishedAt?: string;
authorId?: string;
authorName?: string;
authorEmail?: string;
authorAvatar?: string;
authorUser?: string | {
id?: number;
email?: string;
};
locale?: string;
gotThread?: boolean;
threadFirstItemId?: number;
reports?: {
id?: number;
documentId?: string;
content?: string;
createdAt?: string;
updatedAt?: string;
publishedAt?: string;
locale?: string;
reason?: string;
resolved?: boolean;
}[];
author?: any;
threadOf?: number | {
id?: number;
documentId?: string;
content?: string;
blocked?: boolean;
blockedThread?: boolean;
blockReason?: string;
isAdminComment?: boolean;
removed?: boolean;
approvalStatus?: string;
related?: string;
createdAt?: string;
updatedAt?: string;
publishedAt?: string;
authorId?: string;
authorName?: string;
authorEmail?: string;
authorAvatar?: string;
authorUser?: string | {
id?: number;
email?: string;
};
locale?: string;
gotThread?: boolean;
threadFirstItemId?: number;
reports?: {
id?: number;
documentId?: string;
content?: string;
createdAt?: string;
updatedAt?: string;
publishedAt?: string;
locale?: string;
reason?: string;
resolved?: boolean;
}[];
author?: any;
};
}>;
reportAbuse(ctx: RequestContext): Promise<{
related: {
id?: number;
documentId?: string;
content?: string;
blocked?: boolean;
blockedThread?: boolean;
blockReason?: string;
isAdminComment?: boolean;
removed?: boolean;
approvalStatus?: string;
related?: string;
createdAt?: string;
updatedAt?: string;
publishedAt?: string;
authorId?: string;
authorName?: string;
authorEmail?: string;
authorAvatar?: string;
authorUser?: string | {
id?: number;
email?: string;
};
locale?: string;
gotThread?: boolean;
threadFirstItemId?: number;
reports?: {
id?: number;
documentId?: string;
content?: string;
createdAt?: string;
updatedAt?: string;
publishedAt?: string;
locale?: string;
reason?: string;
resolved?: boolean;
}[];
author?: any;
threadOf?: number | {
id?: number;
documentId?: string;
content?: string;
blocked?: boolean;
blockedThread?: boolean;
blockReason?: string;
isAdminComment?: boolean;
removed?: boolean;
approvalStatus?: string;
related?: string;
createdAt?: string;
updatedAt?: string;
publishedAt?: string;
authorId?: string;
authorName?: string;
authorEmail?: string;
authorAvatar?: string;
authorUser?: string | {
id?: number;
email?: string;
};
locale?: string;
gotThread?: boolean;
threadFirstItemId?: number;
reports?: {
id?: number;
documentId?: string;
content?: string;
createdAt?: string;
updatedAt?: string;
publishedAt?: string;
locale?: string;
reason?: string;
resolved?: boolean;
}[];
author?: any;
};
};
id?: number;
documentId?: string;
content?: string;
createdAt?: string;
updatedAt?: string;
publishedAt?: string;
locale?: string;
reason?: string;
resolved?: boolean;
}>;
removeComment(ctx: RequestContext): Promise<{
id?: number;
documentId?: string;
content?: string;
blocked?: boolean;
blockedThread?: boolean;
blockReason?: string;
isAdminComment?: boolean;
removed?: boolean;
approvalStatus?: string;
related?: string;
createdAt?: string;
updatedAt?: string;
publishedAt?: string;
authorId?: string;
authorName?: string;
authorEmail?: string;
authorAvatar?: string;
authorUser?: string | {
id?: number;
email?: string;
};
locale?: string;
gotThread?: boolean;
threadFirstItemId?: number;
reports?: {
id?: number;
documentId?: string;
content?: string;
createdAt?: string;
updatedAt?: string;
publishedAt?: string;
locale?: string;
reason?: string;
resolved?: boolean;
}[];
author?: any;
threadOf?: number | {
id?: number;
documentId?: string;
content?: string;
blocked?: boolean;
blockedThread?: boolean;
blockReason?: string;
isAdminComment?: boolean;
removed?: boolean;
approvalStatus?: string;
related?: string;
createdAt?: string;
updatedAt?: string;
publishedAt?: string;
authorId?: string;
authorName?: string;
authorEmail?: string;
authorAvatar?: string;
authorUser?: string | {
id?: number;
email?: string;
};
locale?: string;
gotThread?: boolean;
threadFirstItemId?: number;
reports?: {
id?: number;
documentId?: string;
content?: string;
createdAt?: string;
updatedAt?: string;
publishedAt?: string;
locale?: string;
reason?: string;
resolved?: boolean;
}[];
author?: any;
};
}>;
};
export default controllers;