1 | import { body } from "@pnp/queryable";
|
2 | import { _SPQueryable, spInvokableFactory } from "../spqueryable.js";
|
3 | import { extractWebUrl } from "../utils/extract-web-url.js";
|
4 | import { spPost } from "../operations.js";
|
5 | import { combine } from "@pnp/core";
|
6 | export class _Utilities extends _SPQueryable {
|
7 | constructor(base, methodName = "") {
|
8 | super(base);
|
9 | this._url = combine(extractWebUrl(this._url), `_api/SP.Utilities.Utility.${methodName}`);
|
10 | }
|
11 | excute(props) {
|
12 | return spPost(this, body(props));
|
13 | }
|
14 | sendEmail(properties) {
|
15 | if (properties.AdditionalHeaders) {
|
16 |
|
17 | properties.AdditionalHeaders = Reflect.ownKeys(properties.AdditionalHeaders).map(key => ({
|
18 | Key: key,
|
19 | Value: Reflect.get(properties.AdditionalHeaders, key),
|
20 | ValueType: "Edm.String",
|
21 | }));
|
22 | }
|
23 | return UtilitiesCloneFactory(this, "SendEmail").excute({ properties });
|
24 | }
|
25 | getCurrentUserEmailAddresses() {
|
26 | return UtilitiesCloneFactory(this, "GetCurrentUserEmailAddresses").excute({});
|
27 | }
|
28 | resolvePrincipal(input, scopes, sources, inputIsEmailOnly, addToUserInfoList, matchUserInfoList = false) {
|
29 | const params = {
|
30 | addToUserInfoList,
|
31 | input,
|
32 | inputIsEmailOnly,
|
33 | matchUserInfoList,
|
34 | scopes,
|
35 | sources,
|
36 | };
|
37 | return UtilitiesCloneFactory(this, "ResolvePrincipalInCurrentContext").excute(params);
|
38 | }
|
39 | searchPrincipals(input, scopes, sources, groupName, maxCount) {
|
40 | const params = {
|
41 | groupName: groupName,
|
42 | input: input,
|
43 | maxCount: maxCount,
|
44 | scopes: scopes,
|
45 | sources: sources,
|
46 | };
|
47 | return UtilitiesCloneFactory(this, "SearchPrincipalsUsingContextWeb").excute(params);
|
48 | }
|
49 | createEmailBodyForInvitation(pageAddress) {
|
50 | const params = {
|
51 | pageAddress: pageAddress,
|
52 | };
|
53 | return UtilitiesCloneFactory(this, "CreateEmailBodyForInvitation").excute(params);
|
54 | }
|
55 | expandGroupsToPrincipals(inputs, maxCount = 30) {
|
56 | const params = {
|
57 | inputs: inputs,
|
58 | maxCount: maxCount,
|
59 | };
|
60 | const clone = UtilitiesCloneFactory(this, "ExpandGroupsToPrincipals");
|
61 | return clone.excute(params);
|
62 | }
|
63 | }
|
64 | export const Utilities = spInvokableFactory(_Utilities);
|
65 | const UtilitiesCloneFactory = (base, path) => Utilities(base, path);
|
66 |
|
\ | No newline at end of file |