UNPKG

3.86 kBJavaScriptView Raw
1import { __decorate } from "tslib";
2import { defaultPath } from "../decorators.js";
3import { _SPInstance, spInvokableFactory, _SPCollection } from "../spqueryable.js";
4import { hOP } from "@pnp/core";
5import { spPost } from "../operations.js";
6import { body } from "@pnp/queryable";
7let _Favorites = class _Favorites extends _SPInstance {
8 get followedSites() {
9 return FollowedSites(this);
10 }
11 get followedListItems() {
12 return FollowedListItems(this);
13 }
14};
15_Favorites = __decorate([
16 defaultPath("_api/v2.1/favorites")
17], _Favorites);
18export { _Favorites };
19export const Favorites = (baseUrl) => new _Favorites(baseUrl);
20let _FollowedSites = class _FollowedSites extends _SPCollection {
21 /**
22 * Adds a site to user's followed sites
23 *
24 * @param tenantUrl Name of a tenant (e.g. yourtenant.sharepoint.com).
25 * @param siteId Id of a site collection.
26 * @param webId Id of a site.
27 * @param webUrl Absolute URL of a site.
28 */
29 async add(tenantUrl, siteId, webId, webUrl) {
30 const data = await spPost(FollowedListItems(this, "oneDrive.add"), body({
31 value: [
32 {
33 id: [tenantUrl, webId, siteId].join(","),
34 webUrl: webUrl,
35 },
36 ],
37 }));
38 return hOP(data, "value") ? data.value : data;
39 }
40 /**
41 * Removes a site from user's followed sites
42 *
43 * @param tenantUrl Name of a tenant (e.g. yourtenant.sharepoint.com).
44 * @param siteId Id of a site collection.
45 * @param webId Id of a site.
46 * @param webUrl Absolute URL of a site.
47 */
48 async remove(tenantUrl, siteId, webId, webUrl) {
49 await spPost(FollowedListItems(this, "oneDrive.remove"), body({
50 value: [
51 {
52 id: [tenantUrl, webId, siteId].join(","),
53 webUrl: webUrl,
54 },
55 ],
56 }));
57 }
58};
59_FollowedSites = __decorate([
60 defaultPath("followedSites")
61], _FollowedSites);
62export { _FollowedSites };
63export const FollowedSites = spInvokableFactory(_FollowedSites);
64let _FollowedListItems = class _FollowedListItems extends _SPCollection {
65 /**
66 * Adds an item to user's _saved for later_ list
67 *
68 * @param siteId Id of a site collection of an item to add
69 * @param webId Id of a site of an item to add
70 * @param listId Id of a list of an item to add
71 * @param listItemUniqueId Unique id of an item to add
72 */
73 async add(siteId, webId, listId, listItemUniqueId) {
74 const data = await spPost(FollowedListItems(this, "oneDrive.add"), body({
75 value: [
76 {
77 siteId: siteId,
78 webId: webId,
79 listId: listId,
80 listItemUniqueId: listItemUniqueId,
81 },
82 ],
83 }));
84 return hOP(data, "value") ? data.value : data;
85 }
86 /**
87 * Removes an item from user's _saved for later_ list
88 *
89 * @param siteId Id of a site collection of an item to remove
90 * @param webId Id of a site of an item to remove
91 * @param listId Id of a list of an item to remove
92 * @param listItemUniqueId Unique id of an item to remove
93 */
94 async remove(siteId, webId, listId, listItemUniqueId) {
95 await spPost(FollowedListItems(this, "oneDrive.remove"), body({
96 value: [
97 {
98 siteId: siteId,
99 webId: webId,
100 listId: listId,
101 listItemUniqueId: listItemUniqueId,
102 },
103 ],
104 }));
105 }
106};
107_FollowedListItems = __decorate([
108 defaultPath("followedListItems")
109], _FollowedListItems);
110export { _FollowedListItems };
111export const FollowedListItems = spInvokableFactory(_FollowedListItems);
112//# sourceMappingURL=types.js.map
\No newline at end of file