@pnp/sp
Version:
pnp - provides a fluent api for working with SharePoint REST
206 lines • 7.98 kB
JavaScript
import { __decorate } from "tslib";
import { _SPInstance, } from "../spqueryable.js";
import { defaultPath } from "../decorators.js";
import { hOP } from "@pnp/core";
import { body } from "@pnp/queryable";
import { spPost } from "../operations.js";
let _Social = class _Social extends _SPInstance {
get my() {
return MySocial(this);
}
async getFollowedSitesUri() {
const r = await SocialCloneFactory(this, "FollowedSitesUri")();
return r.FollowedSitesUri || r;
}
async getFollowedDocumentsUri() {
const r = await SocialCloneFactory(this, "FollowedDocumentsUri")();
return r.FollowedDocumentsUri || r;
}
async follow(actorInfo) {
return spPost(SocialCloneFactory(this, "follow"), this.createSocialActorInfoRequestBody(actorInfo));
}
async isFollowed(actorInfo) {
return spPost(SocialCloneFactory(this, "isfollowed"), this.createSocialActorInfoRequestBody(actorInfo));
}
async stopFollowing(actorInfo) {
return spPost(SocialCloneFactory(this, "stopfollowing"), this.createSocialActorInfoRequestBody(actorInfo));
}
createSocialActorInfoRequestBody(actorInfo) {
return body({
"actor": {
Id: null,
...actorInfo,
},
});
}
};
_Social = __decorate([
defaultPath("_api/social.following")
], _Social);
export { _Social };
/**
* Get a new Social instance for the particular Url
*/
export const Social = (baseUrl) => new _Social(baseUrl);
const SocialCloneFactory = (baseUrl, paths) => new _Social(baseUrl, paths);
/**
* Current user's Social instance
*/
let _MySocial = class _MySocial extends _SPInstance {
async followed(types) {
const r = await MySocialCloneFactory(this, `followed(types=${types})`)();
return hOP(r, "Followed") ? r.Followed.results : r;
}
async followedCount(types) {
const r = await MySocialCloneFactory(this, `followedcount(types=${types})`)();
return r.FollowedCount || r;
}
async followers() {
const r = await MySocialCloneFactory(this, "followers")();
return hOP(r, "Followers") ? r.Followers.results : r;
}
async suggestions() {
const r = await MySocialCloneFactory(this, "suggestions")();
return hOP(r, "Suggestions") ? r.Suggestions.results : r;
}
};
_MySocial = __decorate([
defaultPath("my")
], _MySocial);
export { _MySocial };
/**
* Invokable factory for IMySocial instances
*/
export const MySocial = (baseUrl, path) => new _MySocial(baseUrl, path);
const MySocialCloneFactory = (baseUrl, path) => new _MySocial(baseUrl, path);
/**
* Social actor type
*
*/
export var SocialActorType;
(function (SocialActorType) {
SocialActorType[SocialActorType["User"] = 0] = "User";
SocialActorType[SocialActorType["Document"] = 1] = "Document";
SocialActorType[SocialActorType["Site"] = 2] = "Site";
SocialActorType[SocialActorType["Tag"] = 3] = "Tag";
})(SocialActorType || (SocialActorType = {}));
/**
* Social actor type
*
*/
/* eslint-disable no-bitwise */
export var SocialActorTypes;
(function (SocialActorTypes) {
SocialActorTypes[SocialActorTypes["None"] = 0] = "None";
SocialActorTypes[SocialActorTypes["User"] = 1] = "User";
SocialActorTypes[SocialActorTypes["Document"] = 2] = "Document";
SocialActorTypes[SocialActorTypes["Site"] = 4] = "Site";
SocialActorTypes[SocialActorTypes["Tag"] = 8] = "Tag";
/**
* The set excludes documents and sites that do not have feeds.
*/
SocialActorTypes[SocialActorTypes["ExcludeContentWithoutFeeds"] = 268435456] = "ExcludeContentWithoutFeeds";
/**
* The set includes group sites
*/
SocialActorTypes[SocialActorTypes["IncludeGroupsSites"] = 536870912] = "IncludeGroupsSites";
/**
* The set includes only items created within the last 24 hours
*/
SocialActorTypes[SocialActorTypes["WithinLast24Hours"] = 1073741824] = "WithinLast24Hours";
})(SocialActorTypes || (SocialActorTypes = {}));
/* eslint-enable no-bitwise */
/**
* Result from following
*
*/
export var SocialFollowResult;
(function (SocialFollowResult) {
SocialFollowResult[SocialFollowResult["Ok"] = 0] = "Ok";
SocialFollowResult[SocialFollowResult["AlreadyFollowing"] = 1] = "AlreadyFollowing";
SocialFollowResult[SocialFollowResult["LimitReached"] = 2] = "LimitReached";
SocialFollowResult[SocialFollowResult["InternalError"] = 3] = "InternalError";
})(SocialFollowResult || (SocialFollowResult = {}));
/**
* Specifies an exception or status code.
*/
export var SocialStatusCode;
(function (SocialStatusCode) {
/**
* The operation completed successfully
*/
SocialStatusCode[SocialStatusCode["OK"] = 0] = "OK";
/**
* The request is invalid.
*/
SocialStatusCode[SocialStatusCode["InvalidRequest"] = 1] = "InvalidRequest";
/**
* The current user is not authorized to perform the operation.
*/
SocialStatusCode[SocialStatusCode["AccessDenied"] = 2] = "AccessDenied";
/**
* The target of the operation was not found.
*/
SocialStatusCode[SocialStatusCode["ItemNotFound"] = 3] = "ItemNotFound";
/**
* The operation is invalid for the target's current state.
*/
SocialStatusCode[SocialStatusCode["InvalidOperation"] = 4] = "InvalidOperation";
/**
* The operation completed without modifying the target.
*/
SocialStatusCode[SocialStatusCode["ItemNotModified"] = 5] = "ItemNotModified";
/**
* The operation failed because an internal error occurred.
*/
SocialStatusCode[SocialStatusCode["InternalError"] = 6] = "InternalError";
/**
* The operation failed because the server could not access the distributed cache.
*/
SocialStatusCode[SocialStatusCode["CacheReadError"] = 7] = "CacheReadError";
/**
* The operation succeeded but the server could not update the distributed cache.
*/
SocialStatusCode[SocialStatusCode["CacheUpdateError"] = 8] = "CacheUpdateError";
/**
* No personal site exists for the current user, and no further information is available.
*/
SocialStatusCode[SocialStatusCode["PersonalSiteNotFound"] = 9] = "PersonalSiteNotFound";
/**
* No personal site exists for the current user, and a previous attempt to create one failed.
*/
SocialStatusCode[SocialStatusCode["FailedToCreatePersonalSite"] = 10] = "FailedToCreatePersonalSite";
/**
* No personal site exists for the current user, and a previous attempt to create one was not authorized.
*/
SocialStatusCode[SocialStatusCode["NotAuthorizedToCreatePersonalSite"] = 11] = "NotAuthorizedToCreatePersonalSite";
/**
* No personal site exists for the current user, and no attempt should be made to create one.
*/
SocialStatusCode[SocialStatusCode["CannotCreatePersonalSite"] = 12] = "CannotCreatePersonalSite";
/**
* The operation was rejected because an internal limit had been reached.
*/
SocialStatusCode[SocialStatusCode["LimitReached"] = 13] = "LimitReached";
/**
* The operation failed because an error occurred during the processing of the specified attachment.
*/
SocialStatusCode[SocialStatusCode["AttachmentError"] = 14] = "AttachmentError";
/**
* The operation succeeded with recoverable errors; the returned data is incomplete.
*/
SocialStatusCode[SocialStatusCode["PartialData"] = 15] = "PartialData";
/**
* A required SharePoint feature is not enabled.
*/
SocialStatusCode[SocialStatusCode["FeatureDisabled"] = 16] = "FeatureDisabled";
/**
* The site's storage quota has been exceeded.
*/
SocialStatusCode[SocialStatusCode["StorageQuotaExceeded"] = 17] = "StorageQuotaExceeded";
/**
* The operation failed because the server could not access the database.
*/
SocialStatusCode[SocialStatusCode["DatabaseError"] = 18] = "DatabaseError";
})(SocialStatusCode || (SocialStatusCode = {}));
//# sourceMappingURL=types.js.map