UNPKG

8 kBJavaScriptView Raw
1import { __decorate } from "tslib";
2import { _SPInstance, } from "../spqueryable.js";
3import { defaultPath } from "../decorators.js";
4import { hOP } from "@pnp/core";
5import { body } from "@pnp/queryable";
6import { spPost } from "../operations.js";
7let _Social = class _Social extends _SPInstance {
8 get my() {
9 return MySocial(this);
10 }
11 async getFollowedSitesUri() {
12 const r = await SocialCloneFactory(this, "FollowedSitesUri")();
13 return r.FollowedSitesUri || r;
14 }
15 async getFollowedDocumentsUri() {
16 const r = await SocialCloneFactory(this, "FollowedDocumentsUri")();
17 return r.FollowedDocumentsUri || r;
18 }
19 async follow(actorInfo) {
20 return await spPost(SocialCloneFactory(this, "follow"), this.createSocialActorInfoRequestBody(actorInfo));
21 }
22 async isFollowed(actorInfo) {
23 return await spPost(SocialCloneFactory(this, "isfollowed"), this.createSocialActorInfoRequestBody(actorInfo));
24 }
25 async stopFollowing(actorInfo) {
26 return await spPost(SocialCloneFactory(this, "stopfollowing"), this.createSocialActorInfoRequestBody(actorInfo));
27 }
28 createSocialActorInfoRequestBody(actorInfo) {
29 return body({
30 "actor": {
31 Id: null,
32 ...actorInfo,
33 },
34 });
35 }
36};
37_Social = __decorate([
38 defaultPath("_api/social.following")
39], _Social);
40export { _Social };
41/**
42 * Get a new Social instance for the particular Url
43 */
44export const Social = (baseUrl) => new _Social(baseUrl);
45const SocialCloneFactory = (baseUrl, paths) => new _Social(baseUrl, paths);
46/**
47 * Current user's Social instance
48 */
49let _MySocial = class _MySocial extends _SPInstance {
50 async followed(types) {
51 const r = await MySocialCloneFactory(this, `followed(types=${types})`)();
52 return hOP(r, "Followed") ? r.Followed.results : r;
53 }
54 async followedCount(types) {
55 const r = await MySocialCloneFactory(this, `followedcount(types=${types})`)();
56 return r.FollowedCount || r;
57 }
58 async followers() {
59 const r = await MySocialCloneFactory(this, "followers")();
60 return hOP(r, "Followers") ? r.Followers.results : r;
61 }
62 async suggestions() {
63 const r = await MySocialCloneFactory(this, "suggestions")();
64 return hOP(r, "Suggestions") ? r.Suggestions.results : r;
65 }
66};
67_MySocial = __decorate([
68 defaultPath("my")
69], _MySocial);
70export { _MySocial };
71/**
72 * Invokable factory for IMySocial instances
73 */
74export const MySocial = (baseUrl, path) => new _MySocial(baseUrl, path);
75const MySocialCloneFactory = (baseUrl, path) => new _MySocial(baseUrl, path);
76/**
77 * Social actor type
78 *
79 */
80export var SocialActorType;
81(function (SocialActorType) {
82 SocialActorType[SocialActorType["User"] = 0] = "User";
83 SocialActorType[SocialActorType["Document"] = 1] = "Document";
84 SocialActorType[SocialActorType["Site"] = 2] = "Site";
85 SocialActorType[SocialActorType["Tag"] = 3] = "Tag";
86})(SocialActorType || (SocialActorType = {}));
87/**
88 * Social actor type
89 *
90 */
91/* eslint-disable no-bitwise */
92export var SocialActorTypes;
93(function (SocialActorTypes) {
94 SocialActorTypes[SocialActorTypes["None"] = 0] = "None";
95 SocialActorTypes[SocialActorTypes["User"] = 1] = "User";
96 SocialActorTypes[SocialActorTypes["Document"] = 2] = "Document";
97 SocialActorTypes[SocialActorTypes["Site"] = 4] = "Site";
98 SocialActorTypes[SocialActorTypes["Tag"] = 8] = "Tag";
99 /**
100 * The set excludes documents and sites that do not have feeds.
101 */
102 SocialActorTypes[SocialActorTypes["ExcludeContentWithoutFeeds"] = 268435456] = "ExcludeContentWithoutFeeds";
103 /**
104 * The set includes group sites
105 */
106 SocialActorTypes[SocialActorTypes["IncludeGroupsSites"] = 536870912] = "IncludeGroupsSites";
107 /**
108 * The set includes only items created within the last 24 hours
109 */
110 SocialActorTypes[SocialActorTypes["WithinLast24Hours"] = 1073741824] = "WithinLast24Hours";
111})(SocialActorTypes || (SocialActorTypes = {}));
112/* eslint-enable no-bitwise */
113/**
114 * Result from following
115 *
116 */
117export var SocialFollowResult;
118(function (SocialFollowResult) {
119 SocialFollowResult[SocialFollowResult["Ok"] = 0] = "Ok";
120 SocialFollowResult[SocialFollowResult["AlreadyFollowing"] = 1] = "AlreadyFollowing";
121 SocialFollowResult[SocialFollowResult["LimitReached"] = 2] = "LimitReached";
122 SocialFollowResult[SocialFollowResult["InternalError"] = 3] = "InternalError";
123})(SocialFollowResult || (SocialFollowResult = {}));
124/**
125 * Specifies an exception or status code.
126 */
127export var SocialStatusCode;
128(function (SocialStatusCode) {
129 /**
130 * The operation completed successfully
131 */
132 SocialStatusCode[SocialStatusCode["OK"] = 0] = "OK";
133 /**
134 * The request is invalid.
135 */
136 SocialStatusCode[SocialStatusCode["InvalidRequest"] = 1] = "InvalidRequest";
137 /**
138 * The current user is not authorized to perform the operation.
139 */
140 SocialStatusCode[SocialStatusCode["AccessDenied"] = 2] = "AccessDenied";
141 /**
142 * The target of the operation was not found.
143 */
144 SocialStatusCode[SocialStatusCode["ItemNotFound"] = 3] = "ItemNotFound";
145 /**
146 * The operation is invalid for the target's current state.
147 */
148 SocialStatusCode[SocialStatusCode["InvalidOperation"] = 4] = "InvalidOperation";
149 /**
150 * The operation completed without modifying the target.
151 */
152 SocialStatusCode[SocialStatusCode["ItemNotModified"] = 5] = "ItemNotModified";
153 /**
154 * The operation failed because an internal error occurred.
155 */
156 SocialStatusCode[SocialStatusCode["InternalError"] = 6] = "InternalError";
157 /**
158 * The operation failed because the server could not access the distributed cache.
159 */
160 SocialStatusCode[SocialStatusCode["CacheReadError"] = 7] = "CacheReadError";
161 /**
162 * The operation succeeded but the server could not update the distributed cache.
163 */
164 SocialStatusCode[SocialStatusCode["CacheUpdateError"] = 8] = "CacheUpdateError";
165 /**
166 * No personal site exists for the current user, and no further information is available.
167 */
168 SocialStatusCode[SocialStatusCode["PersonalSiteNotFound"] = 9] = "PersonalSiteNotFound";
169 /**
170 * No personal site exists for the current user, and a previous attempt to create one failed.
171 */
172 SocialStatusCode[SocialStatusCode["FailedToCreatePersonalSite"] = 10] = "FailedToCreatePersonalSite";
173 /**
174 * No personal site exists for the current user, and a previous attempt to create one was not authorized.
175 */
176 SocialStatusCode[SocialStatusCode["NotAuthorizedToCreatePersonalSite"] = 11] = "NotAuthorizedToCreatePersonalSite";
177 /**
178 * No personal site exists for the current user, and no attempt should be made to create one.
179 */
180 SocialStatusCode[SocialStatusCode["CannotCreatePersonalSite"] = 12] = "CannotCreatePersonalSite";
181 /**
182 * The operation was rejected because an internal limit had been reached.
183 */
184 SocialStatusCode[SocialStatusCode["LimitReached"] = 13] = "LimitReached";
185 /**
186 * The operation failed because an error occurred during the processing of the specified attachment.
187 */
188 SocialStatusCode[SocialStatusCode["AttachmentError"] = 14] = "AttachmentError";
189 /**
190 * The operation succeeded with recoverable errors; the returned data is incomplete.
191 */
192 SocialStatusCode[SocialStatusCode["PartialData"] = 15] = "PartialData";
193 /**
194 * A required SharePoint feature is not enabled.
195 */
196 SocialStatusCode[SocialStatusCode["FeatureDisabled"] = 16] = "FeatureDisabled";
197 /**
198 * The site's storage quota has been exceeded.
199 */
200 SocialStatusCode[SocialStatusCode["StorageQuotaExceeded"] = 17] = "StorageQuotaExceeded";
201 /**
202 * The operation failed because the server could not access the database.
203 */
204 SocialStatusCode[SocialStatusCode["DatabaseError"] = 18] = "DatabaseError";
205})(SocialStatusCode || (SocialStatusCode = {}));
206//# sourceMappingURL=types.js.map
\No newline at end of file