1 | import { __decorate } from "tslib";
|
2 | import { _SPCollection, spInvokableFactory, _SPInstance, deleteable, } from "../spqueryable.js";
|
3 | import { SiteGroups } from "../site-groups/types.js";
|
4 | import { body } from "@pnp/queryable";
|
5 | import { defaultPath } from "../decorators.js";
|
6 | import { spPost, spPostMerge } from "../operations.js";
|
7 | let _SiteUsers = class _SiteUsers extends _SPCollection {
|
8 | |
9 |
|
10 |
|
11 |
|
12 |
|
13 | getById(id) {
|
14 | return SiteUser(this, `getById(${id})`);
|
15 | }
|
16 | |
17 |
|
18 |
|
19 |
|
20 |
|
21 | getByEmail(email) {
|
22 | return SiteUser(this, `getByEmail('${email}')`);
|
23 | }
|
24 | |
25 |
|
26 |
|
27 |
|
28 |
|
29 | getByLoginName(loginName) {
|
30 | return SiteUser(this).concat(`('!@v::${encodeURIComponent(loginName)}')`);
|
31 | }
|
32 | |
33 |
|
34 |
|
35 |
|
36 |
|
37 | removeById(id) {
|
38 | return spPost(SiteUsers(this, `removeById(${id})`));
|
39 | }
|
40 | |
41 |
|
42 |
|
43 |
|
44 |
|
45 | removeByLoginName(loginName) {
|
46 | const o = SiteUsers(this, "removeByLoginName(@v)");
|
47 | o.query.set("@v", `'${encodeURIComponent(loginName)}'`);
|
48 | return spPost(o);
|
49 | }
|
50 | |
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 | async add(loginName) {
|
57 | await spPost(this, body({ LoginName: loginName }));
|
58 | return this.getByLoginName(loginName);
|
59 | }
|
60 | };
|
61 | _SiteUsers = __decorate([
|
62 | defaultPath("siteusers")
|
63 | ], _SiteUsers);
|
64 | export { _SiteUsers };
|
65 | export const SiteUsers = spInvokableFactory(_SiteUsers);
|
66 |
|
67 |
|
68 |
|
69 |
|
70 | export class _SiteUser extends _SPInstance {
|
71 | constructor() {
|
72 | super(...arguments);
|
73 | this.delete = deleteable();
|
74 | }
|
75 | |
76 |
|
77 |
|
78 |
|
79 | get groups() {
|
80 | return SiteGroups(this, "groups");
|
81 | }
|
82 | |
83 |
|
84 |
|
85 |
|
86 |
|
87 | async update(props) {
|
88 | const data = await spPostMerge(this, body(props));
|
89 | return {
|
90 | data,
|
91 | user: this,
|
92 | };
|
93 | }
|
94 | }
|
95 | export const SiteUser = spInvokableFactory(_SiteUser);
|
96 |
|
\ | No newline at end of file |