1 | import type { Node, Text } from '@contentful/rich-text-types';
|
2 | import type { BasicMetaSysProps, DefaultElements, GetCommentParams, GetEntryParams, GetSpaceEnvironmentParams, Link, MakeRequest, SysLink, VersionedLink } from '../common-types';
|
3 | interface LinkWithReference<T extends string> extends Link<T> {
|
4 | sys: Link<T>['sys'] & {
|
5 | ref: string;
|
6 | };
|
7 | }
|
8 | export type CommentSysProps = Pick<BasicMetaSysProps, 'id' | 'version' | 'createdAt' | 'createdBy' | 'updatedAt' | 'updatedBy'> & {
|
9 | type: 'Comment';
|
10 | space: SysLink;
|
11 | environment: SysLink;
|
12 | parentEntity: Link<'ContentType'> | LinkWithReference<'ContentType'> | Link<'Entry'> | LinkWithReference<'Entry'> | VersionedLink<'Workflow'>;
|
13 | parent: Link<'Comment'> | null;
|
14 | };
|
15 | export type PlainTextBodyProperty = 'plain-text';
|
16 | export type RichTextBodyProperty = 'rich-text';
|
17 | export type RichTextBodyFormat = {
|
18 | bodyFormat: RichTextBodyProperty;
|
19 | };
|
20 | export type PlainTextBodyFormat = {
|
21 | bodyFormat?: PlainTextBodyProperty;
|
22 | };
|
23 | export type CommentStatus = 'active' | 'resolved';
|
24 | export type CommentProps = {
|
25 | sys: CommentSysProps;
|
26 | body: string;
|
27 | status: CommentStatus;
|
28 | };
|
29 | export type CreateCommentProps = Omit<CommentProps, 'sys' | 'status'> & {
|
30 | status?: CommentStatus;
|
31 | };
|
32 | export type UpdateCommentProps = Omit<CommentProps, 'sys'> & {
|
33 | sys: Pick<CommentSysProps, 'version'>;
|
34 | };
|
35 | export declare enum CommentNode {
|
36 | Document = "document",
|
37 | Paragraph = "paragraph",
|
38 | Mention = "mention"
|
39 | }
|
40 | export interface Mention {
|
41 | nodeType: CommentNode.Mention;
|
42 | data: {
|
43 | target: Link<'User'> | Link<'Team'>;
|
44 | };
|
45 | content: Text[];
|
46 | }
|
47 | export interface RootParagraph extends Node {
|
48 | nodeType: CommentNode.Paragraph;
|
49 | content: (Text | Mention)[];
|
50 | }
|
51 | export interface RichTextCommentDocument extends Node {
|
52 | nodeType: CommentNode.Document;
|
53 | content: RootParagraph[];
|
54 | }
|
55 | export type RichTextCommentBodyPayload = {
|
56 | body: RichTextCommentDocument;
|
57 | };
|
58 | export type RichTextCommentProps = Omit<CommentProps, 'body'> & RichTextCommentBodyPayload;
|
59 | export type GetCommentParentEntityParams = GetSpaceEnvironmentParams & ({
|
60 | parentEntityType: 'ContentType';
|
61 | parentEntityId: string;
|
62 | parentEntityReference?: string;
|
63 | } | {
|
64 | parentEntityType: 'Entry';
|
65 | parentEntityId: string;
|
66 | parentEntityReference?: string;
|
67 | } | {
|
68 | parentEntityType: 'Workflow';
|
69 | parentEntityId: string;
|
70 | parentEntityVersion?: number;
|
71 | });
|
72 | export type GetManyCommentsParams = (GetEntryParams | GetCommentParentEntityParams) & {
|
73 | status?: CommentStatus;
|
74 | };
|
75 | export type CreateCommentParams = (GetEntryParams | GetCommentParentEntityParams) & {
|
76 | parentCommentId?: string;
|
77 | };
|
78 | export type UpdateCommentParams = GetCommentParams;
|
79 | export type DeleteCommentParams = GetCommentParams & {
|
80 | version: number;
|
81 | };
|
82 | type CommentApi = {
|
83 | update(): Promise<Comment | RichTextComment>;
|
84 | delete(): Promise<void>;
|
85 | };
|
86 | export interface Comment extends CommentProps, DefaultElements<CommentProps>, CommentApi {
|
87 | }
|
88 | export interface RichTextComment extends Omit<CommentProps, 'body'>, RichTextCommentProps, DefaultElements<CommentProps>, CommentApi {
|
89 | }
|
90 |
|
91 |
|
92 |
|
93 | export default function createCommentApi(makeRequest: MakeRequest): CommentApi;
|
94 |
|
95 |
|
96 |
|
97 | export declare function wrapComment(makeRequest: MakeRequest, data: CommentProps | RichTextCommentProps): Comment | RichTextComment;
|
98 |
|
99 |
|
100 |
|
101 | export declare const wrapCommentCollection: (makeRequest: MakeRequest, data: import("../common-types").CollectionProp<CommentProps | RichTextCommentProps>) => import("../common-types").Collection<Comment | RichTextComment, CommentProps | RichTextCommentProps>;
|
102 | export {};
|