jitz-sharepoint-utilities 1.10.62 → 1.10.66

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,4 +28,5 @@ export interface IPersonOrGroup {
28
28
  Name: string;
29
29
  LoginName: string;
30
30
  IsGroup: boolean;
31
+ Groups?: IPersonOrGroup[];
31
32
  }
@@ -7,6 +7,7 @@ export default class CommonRepository implements ICommonRepository {
7
7
  sendEmail(email: IEmail): Promise<boolean>;
8
8
  getData(listName: string, selectFields?: string, expand?: string, filters?: string, orderBy?: string, top?: number, skipTokenUniqueField?: string, skipTokenUniqueFieldValue?: string): Promise<any>;
9
9
  get(url: string): Promise<any>;
10
+ post(url: string, data: any, header?: any): Promise<any>;
10
11
  getFiles(libraryName: string, selectFields: string, filter: string, expandFields: string): Promise<any>;
11
12
  uploadFile(libraryName: string, fileName: string, arrayBuffer: ArrayBuffer): Promise<any>;
12
13
  getFileItem(libraryName: string, fileUrl: string): Promise<any>;
@@ -94,6 +94,25 @@ var CommonRepository = /** @class */ (function () {
94
94
  throw ex;
95
95
  });
96
96
  };
97
+ CommonRepository.prototype.post = function (url, data, header) {
98
+ return this.context.client
99
+ .post(url, data, header)
100
+ .then(function (response) {
101
+ if (response.status >= 200 && response.status < 300) {
102
+ return response.data;
103
+ }
104
+ else {
105
+ return Promise.reject(new Error(JSON.stringify(response)));
106
+ }
107
+ })
108
+ .then(function (data) {
109
+ return data;
110
+ })
111
+ .catch(function (ex) {
112
+ console.log("load Items > JitzSPHttpClient.get()...catch:", ex);
113
+ throw ex;
114
+ });
115
+ };
97
116
  CommonRepository.prototype.getFiles = function (libraryName, selectFields, filter, expandFields) {
98
117
  var url = "/_api/web/lists/getbytitle('" + libraryName + "')/Items?$select=*,File/Name,File/ServerRelativeUrl";
99
118
  if (selectFields != undefined && selectFields.length > 0) {
@@ -5,7 +5,7 @@ var UserService = /** @class */ (function () {
5
5
  var _this = this;
6
6
  this.getCurrentUser = function () {
7
7
  return _this._context.client
8
- .get(_this._webAbsoluteUrl + "/_api/web/CurrentUser")
8
+ .get(_this._webAbsoluteUrl + "/_api/web/CurrentUser/?$expand=groups")
9
9
  .then(function (response) {
10
10
  if (response.status >= 200 && response.status <= 300) {
11
11
  return response.data.d;
@@ -24,6 +24,21 @@ var UserService = /** @class */ (function () {
24
24
  Title: data.Title,
25
25
  IsGroup: false,
26
26
  };
27
+ var groups = [];
28
+ if (data.Groups != undefined && data.Groups.results != undefined) {
29
+ data.Groups.results.map(function (group) {
30
+ groups.push({
31
+ Id: group.Id,
32
+ Email: "",
33
+ EMail: "",
34
+ Name: group.Name,
35
+ IsGroup: true,
36
+ LoginName: group.LoginName,
37
+ Title: group.Title,
38
+ });
39
+ });
40
+ }
41
+ user.Groups = groups;
27
42
  return user;
28
43
  });
29
44
  };
@@ -60,7 +75,7 @@ var UserService = /** @class */ (function () {
60
75
  };
61
76
  this.getUserById = function (id) {
62
77
  return _this._context.client
63
- .get(_this._webAbsoluteUrl + ("/_api/web/getUserById(" + id + ")"))
78
+ .get(_this._webAbsoluteUrl + ("/_api/web/getUserById(" + id + ")?$expand=groups"))
64
79
  .then(function (response) {
65
80
  if (response.status >= 200 && response.status <= 300) {
66
81
  return response.data.d;
@@ -79,6 +94,21 @@ var UserService = /** @class */ (function () {
79
94
  Title: data.Title,
80
95
  IsGroup: false,
81
96
  };
97
+ var groups = [];
98
+ if (data.Groups != undefined && data.Groups.results != undefined) {
99
+ data.Groups.results.map(function (group) {
100
+ groups.push({
101
+ Id: group.Id,
102
+ Email: "",
103
+ EMail: "",
104
+ Name: group.Name,
105
+ IsGroup: true,
106
+ LoginName: group.LoginName,
107
+ Title: group.Title,
108
+ });
109
+ });
110
+ }
111
+ user.Groups = groups;
82
112
  return user;
83
113
  });
84
114
  };
@@ -114,9 +144,8 @@ var UserService = /** @class */ (function () {
114
144
  }
115
145
  })
116
146
  .then(function (data) {
117
- console.log(data);
118
147
  var groups = [];
119
- data.Groups.map(function (group) {
148
+ data.Groups.results.map(function (group) {
120
149
  groups.push({
121
150
  Id: group.Id,
122
151
  Email: "",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jitz-sharepoint-utilities",
3
- "version": "1.10.62",
3
+ "version": "1.10.66",
4
4
  "description": "Essential SharePoint utilities for SharePoint Add-in and SPFx development",
5
5
  "author": "Jithendra Mani",
6
6
  "license": "ISC",