@pnp/sp
Version:
pnp - provides a fluent api for working with SharePoint REST
112 lines • 3.86 kB
JavaScript
import { __decorate } from "tslib";
import { defaultPath } from "../decorators.js";
import { _SPInstance, spInvokableFactory, _SPCollection } from "../spqueryable.js";
import { hOP } from "@pnp/core";
import { spPost } from "../operations.js";
import { body } from "@pnp/queryable";
let _Favorites = class _Favorites extends _SPInstance {
get followedSites() {
return FollowedSites(this);
}
get followedListItems() {
return FollowedListItems(this);
}
};
_Favorites = __decorate([
defaultPath("_api/v2.1/favorites")
], _Favorites);
export { _Favorites };
export const Favorites = (baseUrl) => new _Favorites(baseUrl);
let _FollowedSites = class _FollowedSites extends _SPCollection {
/**
* Adds a site to user's followed sites
*
* @param tenantUrl Name of a tenant (e.g. yourtenant.sharepoint.com).
* @param siteId Id of a site collection.
* @param webId Id of a site.
* @param webUrl Absolute URL of a site.
*/
async add(tenantUrl, siteId, webId, webUrl) {
const data = await spPost(FollowedListItems(this, "oneDrive.add"), body({
value: [
{
id: [tenantUrl, webId, siteId].join(","),
webUrl: webUrl,
},
],
}));
return hOP(data, "value") ? data.value : data;
}
/**
* Removes a site from user's followed sites
*
* @param tenantUrl Name of a tenant (e.g. yourtenant.sharepoint.com).
* @param siteId Id of a site collection.
* @param webId Id of a site.
* @param webUrl Absolute URL of a site.
*/
async remove(tenantUrl, siteId, webId, webUrl) {
await spPost(FollowedListItems(this, "oneDrive.remove"), body({
value: [
{
id: [tenantUrl, webId, siteId].join(","),
webUrl: webUrl,
},
],
}));
}
};
_FollowedSites = __decorate([
defaultPath("followedSites")
], _FollowedSites);
export { _FollowedSites };
export const FollowedSites = spInvokableFactory(_FollowedSites);
let _FollowedListItems = class _FollowedListItems extends _SPCollection {
/**
* Adds an item to user's _saved for later_ list
*
* @param siteId Id of a site collection of an item to add
* @param webId Id of a site of an item to add
* @param listId Id of a list of an item to add
* @param listItemUniqueId Unique id of an item to add
*/
async add(siteId, webId, listId, listItemUniqueId) {
const data = await spPost(FollowedListItems(this, "oneDrive.add"), body({
value: [
{
siteId: siteId,
webId: webId,
listId: listId,
listItemUniqueId: listItemUniqueId,
},
],
}));
return hOP(data, "value") ? data.value : data;
}
/**
* Removes an item from user's _saved for later_ list
*
* @param siteId Id of a site collection of an item to remove
* @param webId Id of a site of an item to remove
* @param listId Id of a list of an item to remove
* @param listItemUniqueId Unique id of an item to remove
*/
async remove(siteId, webId, listId, listItemUniqueId) {
await spPost(FollowedListItems(this, "oneDrive.remove"), body({
value: [
{
siteId: siteId,
webId: webId,
listId: listId,
listItemUniqueId: listItemUniqueId,
},
],
}));
}
};
_FollowedListItems = __decorate([
defaultPath("followedListItems")
], _FollowedListItems);
export { _FollowedListItems };
export const FollowedListItems = spInvokableFactory(_FollowedListItems);
//# sourceMappingURL=types.js.map