1 | import { __decorate } from "tslib";
|
2 | import { defaultPath } from "../decorators.js";
|
3 | import { _SPCollection, spInvokableFactory, _SPInstance, } from "../spqueryable.js";
|
4 | import { odataUrlFrom } from "../utils/odata-url-from.js";
|
5 | import { body } from "@pnp/queryable";
|
6 | import { spDelete, spPost } from "../operations.js";
|
7 | let _Comments = class _Comments extends _SPCollection {
|
8 | |
9 |
|
10 |
|
11 |
|
12 |
|
13 | async add(info) {
|
14 | if (typeof info === "string") {
|
15 | info = { text: info };
|
16 | }
|
17 | const d = await spPost(Comments(this, null), body(info));
|
18 | return Object.assign(this.getById(d.id), d);
|
19 | }
|
20 | |
21 |
|
22 |
|
23 |
|
24 |
|
25 | getById(id) {
|
26 | return Comment(this).concat(`(${id})`);
|
27 | }
|
28 | |
29 |
|
30 |
|
31 | clear() {
|
32 | return spPost(Comments(this, "DeleteAll"));
|
33 | }
|
34 | };
|
35 | _Comments = __decorate([
|
36 | defaultPath("comments")
|
37 | ], _Comments);
|
38 | export { _Comments };
|
39 | export const Comments = spInvokableFactory(_Comments);
|
40 | export class _Comment extends _SPInstance {
|
41 | |
42 |
|
43 |
|
44 | get replies() {
|
45 | return Replies(this);
|
46 | }
|
47 | |
48 |
|
49 |
|
50 | like() {
|
51 | return spPost(Comment(this, "Like"));
|
52 | }
|
53 | |
54 |
|
55 |
|
56 | unlike() {
|
57 | return spPost(Comment(this, "Unlike"));
|
58 | }
|
59 | |
60 |
|
61 |
|
62 | delete() {
|
63 | return spDelete(this);
|
64 | }
|
65 | }
|
66 | export const Comment = spInvokableFactory(_Comment);
|
67 | let _Replies = class _Replies extends _SPCollection {
|
68 | |
69 |
|
70 |
|
71 |
|
72 |
|
73 | async add(info) {
|
74 | if (typeof info === "string") {
|
75 | info = { text: info };
|
76 | }
|
77 | const d = await spPost(Replies(this, null), body(info));
|
78 | return Object.assign(Comment([this, odataUrlFrom(d)]), d);
|
79 | }
|
80 | };
|
81 | _Replies = __decorate([
|
82 | defaultPath("replies")
|
83 | ], _Replies);
|
84 | export { _Replies };
|
85 | export const Replies = spInvokableFactory(_Replies);
|
86 |
|
\ | No newline at end of file |