1 | import { __decorate } from "tslib";
|
2 | import { _SPInstance, SPCollection, spInvokableFactory, _SPQueryable, } from "../spqueryable.js";
|
3 | import { body } from "@pnp/queryable";
|
4 | import { defaultPath } from "../decorators.js";
|
5 | import { spPost } from "../operations.js";
|
6 | import { AssignFrom } from "@pnp/core";
|
7 | export class _Profiles extends _SPInstance {
|
8 | |
9 |
|
10 |
|
11 |
|
12 |
|
13 | constructor(baseUrl, path = "_api/sp.userprofiles.peoplemanager") {
|
14 | super(baseUrl, path);
|
15 | this.clientPeoplePickerQuery = (new ClientPeoplePickerQuery(baseUrl)).using(AssignFrom(this));
|
16 | this.profileLoader = (new ProfileLoader(baseUrl)).using(AssignFrom(this));
|
17 | }
|
18 | |
19 |
|
20 |
|
21 | getEditProfileLink() {
|
22 | return Profiles(this, "EditProfileLink")();
|
23 | }
|
24 | |
25 |
|
26 |
|
27 | getIsMyPeopleListPublic() {
|
28 | return Profiles(this, "IsMyPeopleListPublic")();
|
29 | }
|
30 | |
31 |
|
32 |
|
33 |
|
34 |
|
35 | amIFollowedBy(loginName) {
|
36 | const q = Profiles(this, "amifollowedby(@v)");
|
37 | q.query.set("@v", `'${encodeURIComponent(loginName)}'`);
|
38 | return q();
|
39 | }
|
40 | |
41 |
|
42 |
|
43 |
|
44 |
|
45 | amIFollowing(loginName) {
|
46 | const q = Profiles(this, "amifollowing(@v)");
|
47 | q.query.set("@v", `'${encodeURIComponent(loginName)}'`);
|
48 | return q();
|
49 | }
|
50 | |
51 |
|
52 |
|
53 |
|
54 |
|
55 | getFollowedTags(maxCount = 20) {
|
56 | return Profiles(this, `getfollowedtags(${maxCount})`)();
|
57 | }
|
58 | |
59 |
|
60 |
|
61 |
|
62 |
|
63 | getFollowersFor(loginName) {
|
64 | const q = Profiles(this, "getfollowersfor(@v)");
|
65 | q.query.set("@v", `'${encodeURIComponent(loginName)}'`);
|
66 | return q();
|
67 | }
|
68 | |
69 |
|
70 |
|
71 |
|
72 | get myFollowers() {
|
73 | return SPCollection(this, "getmyfollowers");
|
74 | }
|
75 | |
76 |
|
77 |
|
78 |
|
79 | get myProperties() {
|
80 | return Profiles(this, "getmyproperties");
|
81 | }
|
82 | |
83 |
|
84 |
|
85 |
|
86 |
|
87 | getPeopleFollowedBy(loginName) {
|
88 | const q = Profiles(this, "getpeoplefollowedby(@v)");
|
89 | q.query.set("@v", `'${encodeURIComponent(loginName)}'`);
|
90 | return q();
|
91 | }
|
92 | |
93 |
|
94 |
|
95 |
|
96 |
|
97 | getPropertiesFor(loginName) {
|
98 | const q = Profiles(this, "getpropertiesfor(@v)");
|
99 | q.query.set("@v", `'${encodeURIComponent(loginName)}'`);
|
100 | return q();
|
101 | }
|
102 | |
103 |
|
104 |
|
105 |
|
106 | get trendingTags() {
|
107 | const q = Profiles(this, null);
|
108 | q.concat(".gettrendingtags");
|
109 | return q();
|
110 | }
|
111 | |
112 |
|
113 |
|
114 |
|
115 |
|
116 |
|
117 | getUserProfilePropertyFor(loginName, propertyName) {
|
118 | const q = Profiles(this, `getuserprofilepropertyfor(accountname=@v, propertyname='${propertyName}')`);
|
119 | q.query.set("@v", `'${encodeURIComponent(loginName)}'`);
|
120 | return q();
|
121 | }
|
122 | |
123 |
|
124 |
|
125 |
|
126 |
|
127 | hideSuggestion(loginName) {
|
128 | const q = Profiles(this, "hidesuggestion(@v)");
|
129 | q.query.set("@v", `'${encodeURIComponent(loginName)}'`);
|
130 | return spPost(q);
|
131 | }
|
132 | |
133 |
|
134 |
|
135 |
|
136 |
|
137 |
|
138 | isFollowing(follower, followee) {
|
139 | const q = Profiles(this, null);
|
140 | q.concat(".isfollowing(possiblefolloweraccountname=@v, possiblefolloweeaccountname=@y)");
|
141 | q.query.set("@v", `'${encodeURIComponent(follower)}'`);
|
142 | q.query.set("@y", `'${encodeURIComponent(followee)}'`);
|
143 | return q();
|
144 | }
|
145 | |
146 |
|
147 |
|
148 |
|
149 |
|
150 | setMyProfilePic(profilePicSource) {
|
151 | return new Promise((resolve, reject) => {
|
152 | const reader = new FileReader();
|
153 | reader.onload = async (e) => {
|
154 | const buffer = e.target.result;
|
155 | try {
|
156 | await spPost(Profiles(this, "setmyprofilepicture"), { body: buffer });
|
157 | resolve();
|
158 | }
|
159 | catch (e) {
|
160 | reject(e);
|
161 | }
|
162 | };
|
163 | reader.readAsArrayBuffer(profilePicSource);
|
164 | });
|
165 | }
|
166 | |
167 |
|
168 |
|
169 |
|
170 |
|
171 |
|
172 |
|
173 | setSingleValueProfileProperty(accountName, propertyName, propertyValue) {
|
174 | return spPost(Profiles(this, "SetSingleValueProfileProperty"), body({
|
175 | accountName,
|
176 | propertyName,
|
177 | propertyValue,
|
178 | }));
|
179 | }
|
180 | |
181 |
|
182 |
|
183 |
|
184 |
|
185 |
|
186 |
|
187 | setMultiValuedProfileProperty(accountName, propertyName, propertyValues) {
|
188 | return spPost(Profiles(this, "SetMultiValuedProfileProperty"), body({
|
189 | accountName,
|
190 | propertyName,
|
191 | propertyValues,
|
192 | }));
|
193 | }
|
194 | |
195 |
|
196 |
|
197 |
|
198 |
|
199 | createPersonalSiteEnqueueBulk(...emails) {
|
200 | return this.profileLoader.createPersonalSiteEnqueueBulk(emails);
|
201 | }
|
202 | |
203 |
|
204 |
|
205 |
|
206 | get ownerUserProfile() {
|
207 | return this.profileLoader.ownerUserProfile;
|
208 | }
|
209 | |
210 |
|
211 |
|
212 | get userProfile() {
|
213 | return this.profileLoader.userProfile;
|
214 | }
|
215 | |
216 |
|
217 |
|
218 |
|
219 |
|
220 | createPersonalSite(interactiveRequest = false) {
|
221 | return this.profileLoader.createPersonalSite(interactiveRequest);
|
222 | }
|
223 | |
224 |
|
225 |
|
226 |
|
227 |
|
228 | shareAllSocialData(share) {
|
229 | return this.profileLoader.shareAllSocialData(share);
|
230 | }
|
231 | |
232 |
|
233 |
|
234 |
|
235 |
|
236 | clientPeoplePickerResolveUser(queryParams) {
|
237 | return this.clientPeoplePickerQuery.clientPeoplePickerResolveUser(queryParams);
|
238 | }
|
239 | |
240 |
|
241 |
|
242 |
|
243 |
|
244 | clientPeoplePickerSearchUser(queryParams) {
|
245 | return this.clientPeoplePickerQuery.clientPeoplePickerSearchUser(queryParams);
|
246 | }
|
247 | }
|
248 | export const Profiles = spInvokableFactory(_Profiles);
|
249 | let ProfileLoader = class ProfileLoader extends _SPQueryable {
|
250 | |
251 |
|
252 |
|
253 |
|
254 |
|
255 | createPersonalSiteEnqueueBulk(emails) {
|
256 | return spPost(ProfileLoaderFactory(this, "createpersonalsiteenqueuebulk"), body({ "emailIDs": emails }));
|
257 | }
|
258 | |
259 |
|
260 |
|
261 |
|
262 | get ownerUserProfile() {
|
263 | return spPost(this.getParent(ProfileLoaderFactory, "_api/sp.userprofiles.profileloader.getowneruserprofile"));
|
264 | }
|
265 | |
266 |
|
267 |
|
268 |
|
269 | get userProfile() {
|
270 | return spPost(ProfileLoaderFactory(this, "getuserprofile"));
|
271 | }
|
272 | |
273 |
|
274 |
|
275 |
|
276 |
|
277 | createPersonalSite(interactiveRequest = false) {
|
278 | return spPost(ProfileLoaderFactory(this, `getuserprofile/createpersonalsiteenque(${interactiveRequest})`));
|
279 | }
|
280 | |
281 |
|
282 |
|
283 |
|
284 |
|
285 | shareAllSocialData(share) {
|
286 | return spPost(ProfileLoaderFactory(this, `getuserprofile/shareallsocialdata(${share})`));
|
287 | }
|
288 | };
|
289 | ProfileLoader = __decorate([
|
290 | defaultPath("_api/sp.userprofiles.profileloader.getprofileloader")
|
291 | ], ProfileLoader);
|
292 | const ProfileLoaderFactory = (baseUrl, path) => {
|
293 | return new ProfileLoader(baseUrl, path);
|
294 | };
|
295 | let ClientPeoplePickerQuery = class ClientPeoplePickerQuery extends _SPQueryable {
|
296 | |
297 |
|
298 |
|
299 |
|
300 |
|
301 | async clientPeoplePickerResolveUser(queryParams) {
|
302 | const q = ClientPeoplePickerFactory(this, null);
|
303 | q.concat(".clientpeoplepickerresolveuser");
|
304 | const res = await spPost(q, this.getBodyFrom(queryParams));
|
305 | return JSON.parse(typeof res === "object" ? res.ClientPeoplePickerResolveUser : res);
|
306 | }
|
307 | |
308 |
|
309 |
|
310 |
|
311 |
|
312 | async clientPeoplePickerSearchUser(queryParams) {
|
313 | const q = ClientPeoplePickerFactory(this, null);
|
314 | q.concat(".clientpeoplepickersearchuser");
|
315 | const res = await spPost(q, this.getBodyFrom(queryParams));
|
316 | return JSON.parse(typeof res === "object" ? res.ClientPeoplePickerSearchUser : res);
|
317 | }
|
318 | |
319 |
|
320 |
|
321 |
|
322 |
|
323 | getBodyFrom(queryParams) {
|
324 | return body({ queryParams });
|
325 | }
|
326 | };
|
327 | ClientPeoplePickerQuery = __decorate([
|
328 | defaultPath("_api/sp.ui.applicationpages.clientpeoplepickerwebserviceinterface")
|
329 | ], ClientPeoplePickerQuery);
|
330 | const ClientPeoplePickerFactory = (baseUrl, path) => {
|
331 | return new ClientPeoplePickerQuery(baseUrl, path);
|
332 | };
|
333 |
|
334 |
|
335 |
|
336 | export var UrlZone;
|
337 | (function (UrlZone) {
|
338 | |
339 |
|
340 |
|
341 | UrlZone[UrlZone["DefaultZone"] = 0] = "DefaultZone";
|
342 | |
343 |
|
344 |
|
345 | UrlZone[UrlZone["Intranet"] = 1] = "Intranet";
|
346 | |
347 |
|
348 |
|
349 | UrlZone[UrlZone["Internet"] = 2] = "Internet";
|
350 | |
351 |
|
352 |
|
353 | UrlZone[UrlZone["Custom"] = 3] = "Custom";
|
354 | |
355 |
|
356 |
|
357 | UrlZone[UrlZone["Extranet"] = 4] = "Extranet";
|
358 | })(UrlZone || (UrlZone = {}));
|
359 |
|
\ | No newline at end of file |