UNPKG

7.04 kBTypeScriptView Raw
1import type { RawAxiosRequestHeaders } from 'axios';
2import type { CollectionProp, GetCommentParams, QueryParams } from '../../common-types';
3import type { CommentProps, CreateCommentParams, CreateCommentProps, DeleteCommentParams, GetManyCommentsParams, PlainTextBodyFormat, RichTextBodyFormat, RichTextCommentBodyPayload, RichTextCommentProps, UpdateCommentParams, UpdateCommentProps } from '../../entities/comment';
4import type { OptionalDefaults } from '../wrappers/wrap';
5export type CommentPlainClientAPI = {
6 /** Fetches a plain text comment
7 *
8 * @param params Space ID, Comment ID, Entry ID, Environment ID
9 * @returns the plain text comment
10 * @throws if the request fails, or the comment is not found
11 * @example
12 * ```javascript
13 * const comment = await client.comment.get({
14 * spaceId: '<space_id>',
15 * commentId: '<comment_id>',
16 * entryId: '<entry_id>',
17 * environmentId: '<environment_id>',
18 * bodyFormat: 'plain-text',
19 * });
20 * ```
21 * */
22 get(params: OptionalDefaults<GetCommentParams> & PlainTextBodyFormat): Promise<CommentProps>;
23 /** Fetches a rich text comment
24 *
25 * @param params Space ID, Comment ID, Entry ID, Environment ID
26 * @returns the rich text comment
27 * @throws if the request fails, or the comment is not found
28 * @example
29 * ```javascript
30 * const comment = await client.comment.get({
31 * spaceId: '<space_id>',
32 * commentId: '<comment_id>',
33 * entryId: '<entry_id>',
34 * environmentId: '<environment_id>',
35 * bodyFormat: 'rich-text',
36 * });
37 * ```
38 * */
39 get(params: OptionalDefaults<GetCommentParams> & RichTextBodyFormat): Promise<RichTextCommentProps>;
40 /** Fetches all plain text comments on an entry
41 *
42 * @param params Space ID, Entry ID, Environment ID, and query parameters
43 * @returns a collection of plain text comments
44 * @throws if the request fails or the comments are not found
45 * @example
46 * ```javascript
47 * const comments = await client.comment.getMany({
48 * spaceId: '<space_id>',
49 * entryId: '<entry_id>',
50 * environmentId: '<environment_id>',
51 * bodyFormat: 'plain-text',
52 * query: {
53 * limit: 100,
54 * }
55 * });
56 * ```
57 * */
58 getMany(params: OptionalDefaults<GetManyCommentsParams & PlainTextBodyFormat & QueryParams>): Promise<CollectionProp<CommentProps>>;
59 /** Fetches all rich text comments on an entry
60 *
61 * @param params Space ID, Entry ID, Environment ID, and query parameters
62 * @returns a collection of rich text comments
63 * @throws if the request fails or the comments are not found
64 * @example
65 * ```javascript
66 * const comments = await client.comment.getMany({
67 * spaceId: '<space_id>',
68 * entryId: '<entry_id>',
69 * environmentId: '<environment_id>',
70 * bodyFormat: 'rich-text',
71 * query: {
72 * limit: 100,
73 * }
74 * });
75 * ```
76 * */
77 getMany(params: OptionalDefaults<GetManyCommentsParams & QueryParams & RichTextBodyFormat>): Promise<CollectionProp<RichTextCommentProps>>;
78 /** Creates a plain text comment
79 *
80 * @param params
81 * @returns a plain text comment
82 * @throws if the request fails, the entry is not found, or the payload is malformed
83 * @example
84 * ```javascript
85 * const comment = await client.comment.create(
86 * {
87 * spaceId: '<space_id>',
88 * entryId: '<entry_id>',
89 * environmentId: '<environment_id>',
90 * bodyFormat: 'plain-text',
91 * },
92 * {
93 * body: 'Looks good to me!',
94 * status: 'active',
95 * }
96 * );
97 * ```
98 */
99 create(params: OptionalDefaults<CreateCommentParams>, rawData: CreateCommentProps, headers?: RawAxiosRequestHeaders): Promise<CommentProps>;
100 /** Creates a rich text comment
101 *
102 * @param params
103 * @returns a rich text comment
104 * @throws if the request fails, the entry is not found, or the payload is malformed
105 * @example
106 * ```javascript
107 * const comment = await client.comment.create(
108 * {
109 * spaceId: '<space_id>',
110 * entryId: '<entry_id>',
111 * environmentId: '<environment_id>',
112 * bodyFormat: 'rich-text',
113 * },
114 * {
115 * body: 'Looks good to me!',
116 * status: 'active',
117 * }
118 * );
119 * ```
120 */
121 create(params: OptionalDefaults<CreateCommentParams>, rawData: RichTextCommentBodyPayload, headers?: RawAxiosRequestHeaders): Promise<RichTextCommentProps>;
122 /** Updates a plain text comment
123 *
124 * @param params
125 * @returns a plain text comment
126 * @throws if the request fails, the comment is not found, or the payload is malformed
127 * @example
128 * ```javascript
129 * let comment = await client.comment.get({
130 * spaceId: '<space_id>',
131 * commentId: '<comment_id>',
132 * entryId: '<entry_id>',
133 * environmentId: '<environment_id>',
134 * bodyFormat: 'plain-text',
135 * });
136 *
137 * comment = await client.comment.update(
138 * {
139 * spaceId: '<space_id>',
140 * commentId: '<comment_id>',
141 * entryId: '<entry_id>',
142 * environmentId: '<environment_id>',
143 * },
144 * {
145 * ...comment,
146 * text: 'This is a new comment.',
147 * }
148 * );
149 * ```
150 */
151 update(params: OptionalDefaults<UpdateCommentParams>, rawData: UpdateCommentProps, headers?: RawAxiosRequestHeaders): Promise<CommentProps>;
152 /** Updates a plain text comment
153 *
154 * @param params
155 * @returns a rich text comment
156 * @throws if the request fails, the comment is not found, or the payload is malformed
157 * @example
158 * ```javascript
159 * let comment = await client.comment.get({
160 * spaceId: '<space_id>',
161 * commentId: '<comment_id>',
162 * entryId: '<entry_id>',
163 * environmentId: '<environment_id>',
164 * bodyFormat: 'rich-text',
165 * });
166 *
167 * comment = await client.comment.update(
168 * {
169 * spaceId: '<space_id>',
170 * commentId: '<comment_id>',
171 * entryId: '<entry_id>',
172 * environmentId: '<environment_id>',
173 * },
174 * {
175 * ...comment,
176 * text: 'This is a new comment.',
177 * }
178 * );
179 * ```
180 */
181 update(params: OptionalDefaults<UpdateCommentParams>, rawData: Omit<UpdateCommentProps, 'body'> & RichTextCommentBodyPayload, headers?: RawAxiosRequestHeaders): Promise<RichTextCommentProps>;
182 /** Deletes a comment
183 *
184 * @param params
185 * @returns void
186 * @throws if the request fails, or the comment is not found
187 * @example
188 * ```javascript
189 * await client.comment.delete({
190 * spaceId: '<space_id>',
191 * commentId: '<comment_id>',
192 * entryId: '<entry_id>',
193 * environmentId: '<environment_id>',
194 * });
195 * ```
196 */
197 delete(params: OptionalDefaults<DeleteCommentParams>): Promise<void>;
198};