jitz-sharepoint-utilities 2.0.14 → 2.0.15
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.
- package/lib/common/IModels.d.ts +40 -0
- package/lib/common/IModels.js +2 -0
- package/lib/common/IObjects.d.ts +72 -0
- package/lib/common/IObjects.js +30 -0
- package/lib/controls/JitzGrid.d.ts +75 -0
- package/lib/controls/JitzGrid.js +606 -0
- package/lib/controls/JitzImage.d.ts +14 -0
- package/lib/controls/JitzImage.js +37 -0
- package/lib/controls/JitzPeoplePicker.d.ts +49 -0
- package/lib/controls/JitzPeoplePicker.js +311 -0
- package/lib/controls/JitzPersonInfo.d.ts +32 -0
- package/lib/controls/JitzPersonInfo.js +98 -0
- package/lib/controls/JitzPersona.d.ts +23 -0
- package/lib/controls/JitzPersona.js +48 -0
- package/lib/data/context/CommonRepository.d.ts +17 -0
- package/lib/data/context/CommonRepository.js +287 -0
- package/lib/data/context/JitzContext.d.ts +13 -0
- package/lib/data/context/JitzContext.js +80 -0
- package/lib/data/context/JitzSPContext.d.ts +8 -0
- package/lib/data/context/JitzSPContext.js +58 -0
- package/lib/data/context/JitzSPHttpClient.d.ts +14 -0
- package/lib/data/context/JitzSPHttpClient.js +173 -0
- package/lib/data/context/List.d.ts +39 -0
- package/lib/data/context/List.js +492 -0
- package/lib/data/context/Repository.d.ts +22 -0
- package/lib/data/context/Repository.js +486 -0
- package/lib/data/interfaces/ICommonRepository.d.ts +6 -0
- package/lib/data/interfaces/ICommonRepository.js +2 -0
- package/lib/data/interfaces/IJitzContext.d.ts +10 -0
- package/lib/data/interfaces/IJitzContext.js +2 -0
- package/lib/data/interfaces/IJitzSPContext.d.ts +6 -0
- package/lib/data/interfaces/IJitzSPContext.js +2 -0
- package/lib/data/interfaces/IJitzSPHttpClient.d.ts +6 -0
- package/lib/data/interfaces/IJitzSPHttpClient.js +2 -0
- package/lib/data/interfaces/IList.d.ts +26 -0
- package/lib/data/interfaces/IList.js +2 -0
- package/lib/data/interfaces/IModels.d.ts +32 -0
- package/lib/data/interfaces/IModels.js +2 -0
- package/lib/data/interfaces/IRepository.d.ts +17 -0
- package/lib/data/interfaces/IRepository.js +2 -0
- package/lib/jitzHttpClient.d.ts +11 -0
- package/lib/jitzHttpClient.js +37 -0
- package/lib/jitzSPHttpClient.d.ts +30 -0
- package/lib/jitzSPHttpClient.js +193 -0
- package/lib/repositories/CommonRepository.d.ts +17 -0
- package/lib/repositories/CommonRepository.js +287 -0
- package/lib/repositories/ICommonRepository.d.ts +6 -0
- package/lib/repositories/ICommonRepository.js +2 -0
- package/lib/repositories/IRepository.d.ts +13 -0
- package/lib/repositories/IRepository.js +2 -0
- package/lib/repositories/Repository.d.ts +18 -0
- package/lib/repositories/Repository.js +392 -0
- package/lib/services/GraphService.d.ts +10 -0
- package/lib/services/GraphService.js +103 -0
- package/lib/services/UserService.d.ts +15 -0
- package/lib/services/UserService.js +202 -0
- package/lib/services/UtilityService.d.ts +29 -0
- package/lib/services/UtilityService.js +254 -0
- package/package.json +1 -1
@@ -0,0 +1,392 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
15
|
+
function step(op) {
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
20
|
+
switch (op[0]) {
|
21
|
+
case 0: case 1: t = op; break;
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
25
|
+
default:
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
30
|
+
if (t[2]) _.ops.pop();
|
31
|
+
_.trys.pop(); continue;
|
32
|
+
}
|
33
|
+
op = body.call(thisArg, _);
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
36
|
+
}
|
37
|
+
};
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
39
|
+
var Repository = /** @class */ (function () {
|
40
|
+
function Repository(context, listName) {
|
41
|
+
this.context = context;
|
42
|
+
this.listName = listName;
|
43
|
+
}
|
44
|
+
Repository.prototype.getAll = function (selectFields, expand, filters, orderBy, top, skipTokenUniqueField, skipTokenUniqueFieldValue) {
|
45
|
+
var queryUrlGetAllItems = "".concat(this.context.siteUrl, "/_api/web/lists/GetByTitle('") +
|
46
|
+
this.listName +
|
47
|
+
"')/items";
|
48
|
+
if (selectFields != null && selectFields != "") {
|
49
|
+
queryUrlGetAllItems = queryUrlGetAllItems + "?$select=" + selectFields;
|
50
|
+
}
|
51
|
+
else {
|
52
|
+
queryUrlGetAllItems = queryUrlGetAllItems + "?$select=*";
|
53
|
+
}
|
54
|
+
if (expand != null && expand != "") {
|
55
|
+
queryUrlGetAllItems = queryUrlGetAllItems + "&$expand=" + expand;
|
56
|
+
}
|
57
|
+
if (filters != null && filters != "") {
|
58
|
+
queryUrlGetAllItems = queryUrlGetAllItems + "&$filter=" + filters;
|
59
|
+
}
|
60
|
+
if (orderBy != null && orderBy != "") {
|
61
|
+
queryUrlGetAllItems = queryUrlGetAllItems + "&$orderby=" + orderBy;
|
62
|
+
}
|
63
|
+
if (top != null && top != undefined && top > 0) {
|
64
|
+
queryUrlGetAllItems = queryUrlGetAllItems + "&$top=" + top;
|
65
|
+
}
|
66
|
+
if (skipTokenUniqueField != null &&
|
67
|
+
skipTokenUniqueField != undefined &&
|
68
|
+
skipTokenUniqueFieldValue != null &&
|
69
|
+
skipTokenUniqueFieldValue != undefined) {
|
70
|
+
if (skipTokenUniqueField == "Id" || skipTokenUniqueField == "id") {
|
71
|
+
skipTokenUniqueField = "ID";
|
72
|
+
}
|
73
|
+
queryUrlGetAllItems =
|
74
|
+
queryUrlGetAllItems +
|
75
|
+
"&$skiptoken=Paged=TRUE%26p_".concat(skipTokenUniqueField, "=").concat(skipTokenUniqueFieldValue);
|
76
|
+
}
|
77
|
+
return this.context.client
|
78
|
+
.get(queryUrlGetAllItems)
|
79
|
+
.then(function (response) {
|
80
|
+
if (response.status >= 200 && response.status < 300) {
|
81
|
+
return response.data.d.results;
|
82
|
+
}
|
83
|
+
else {
|
84
|
+
return Promise.reject(new Error(JSON.stringify(response)));
|
85
|
+
}
|
86
|
+
})
|
87
|
+
.then(function (data) {
|
88
|
+
var items = [];
|
89
|
+
if (data) {
|
90
|
+
for (var i = 0; i < data.length; i++) {
|
91
|
+
var item = data[i];
|
92
|
+
items.push(item);
|
93
|
+
}
|
94
|
+
}
|
95
|
+
return items;
|
96
|
+
})
|
97
|
+
.catch(function (ex) {
|
98
|
+
console.log("load Items > JitzSPHttpClient.get()...catch:", ex);
|
99
|
+
throw ex;
|
100
|
+
});
|
101
|
+
};
|
102
|
+
Repository.prototype.getAllRecursive = function (selectFields_1, expand_1, filters_1, orderBy_1, top_1) {
|
103
|
+
return __awaiter(this, arguments, void 0, function (selectFields, expand, filters, orderBy, top, maxRecursiveCount) {
|
104
|
+
var items, queryUrlGetAllItems;
|
105
|
+
var _this = this;
|
106
|
+
if (maxRecursiveCount === void 0) { maxRecursiveCount = 5; }
|
107
|
+
return __generator(this, function (_a) {
|
108
|
+
switch (_a.label) {
|
109
|
+
case 0:
|
110
|
+
items = [];
|
111
|
+
queryUrlGetAllItems = "".concat(this.context.siteUrl, "/_api/web/lists/GetByTitle('") +
|
112
|
+
this.listName +
|
113
|
+
"')/items";
|
114
|
+
if (selectFields != null && selectFields != "") {
|
115
|
+
queryUrlGetAllItems = queryUrlGetAllItems + "?$select=" + selectFields;
|
116
|
+
}
|
117
|
+
else {
|
118
|
+
queryUrlGetAllItems = queryUrlGetAllItems + "?$select=*";
|
119
|
+
}
|
120
|
+
if (expand != null && expand != "") {
|
121
|
+
queryUrlGetAllItems = queryUrlGetAllItems + "&$expand=" + expand;
|
122
|
+
}
|
123
|
+
if (filters != null && filters != "") {
|
124
|
+
queryUrlGetAllItems = queryUrlGetAllItems + "&$filter=" + filters;
|
125
|
+
}
|
126
|
+
if (orderBy != null && orderBy != "") {
|
127
|
+
queryUrlGetAllItems = queryUrlGetAllItems + "&$orderby=" + orderBy;
|
128
|
+
}
|
129
|
+
if (top != null && top != undefined && top > 0) {
|
130
|
+
queryUrlGetAllItems = queryUrlGetAllItems + "&$top=" + top;
|
131
|
+
}
|
132
|
+
return [4 /*yield*/, this.context.client
|
133
|
+
.get(queryUrlGetAllItems)
|
134
|
+
.then(function (response) { return __awaiter(_this, void 0, void 0, function () {
|
135
|
+
return __generator(this, function (_a) {
|
136
|
+
switch (_a.label) {
|
137
|
+
case 0:
|
138
|
+
if (!(response.status >= 200 && response.status < 300)) return [3 /*break*/, 2];
|
139
|
+
return [4 /*yield*/, response.data.d];
|
140
|
+
case 1: return [2 /*return*/, _a.sent()];
|
141
|
+
case 2: return [2 /*return*/, Promise.reject(new Error(JSON.stringify(response)))];
|
142
|
+
}
|
143
|
+
});
|
144
|
+
}); })
|
145
|
+
.then(function (data) { return __awaiter(_this, void 0, void 0, function () {
|
146
|
+
var i, item, returnItem;
|
147
|
+
return __generator(this, function (_a) {
|
148
|
+
switch (_a.label) {
|
149
|
+
case 0:
|
150
|
+
if (data.results) {
|
151
|
+
for (i = 0; i < data.results.length; i++) {
|
152
|
+
item = data.results[i];
|
153
|
+
items.push(item);
|
154
|
+
}
|
155
|
+
}
|
156
|
+
returnItem = {
|
157
|
+
__next: data.__next,
|
158
|
+
results: items,
|
159
|
+
};
|
160
|
+
if (!(returnItem.__next != undefined && returnItem.__next.length > 0)) return [3 /*break*/, 2];
|
161
|
+
return [4 /*yield*/, this.recursiveFetch(returnItem.__next, 2, maxRecursiveCount, returnItem.results)];
|
162
|
+
case 1:
|
163
|
+
items = _a.sent();
|
164
|
+
_a.label = 2;
|
165
|
+
case 2: return [2 /*return*/];
|
166
|
+
}
|
167
|
+
});
|
168
|
+
}); })
|
169
|
+
.catch(function (ex) {
|
170
|
+
console.log("load Items > JitzSPHttpClient.get()...catch:", ex);
|
171
|
+
throw ex;
|
172
|
+
})];
|
173
|
+
case 1:
|
174
|
+
_a.sent();
|
175
|
+
return [2 /*return*/, items];
|
176
|
+
}
|
177
|
+
});
|
178
|
+
});
|
179
|
+
};
|
180
|
+
Repository.prototype.recursiveFetch = function (url_1) {
|
181
|
+
return __awaiter(this, arguments, void 0, function (url, recursiveCount, maxRecursiveCount, items) {
|
182
|
+
var _this = this;
|
183
|
+
if (recursiveCount === void 0) { recursiveCount = 1; }
|
184
|
+
if (maxRecursiveCount === void 0) { maxRecursiveCount = 5; }
|
185
|
+
if (items === void 0) { items = []; }
|
186
|
+
return __generator(this, function (_a) {
|
187
|
+
switch (_a.label) {
|
188
|
+
case 0:
|
189
|
+
items = items || [];
|
190
|
+
return [4 /*yield*/, this.context.client
|
191
|
+
.get(url)
|
192
|
+
.then(function (response) { return __awaiter(_this, void 0, void 0, function () {
|
193
|
+
return __generator(this, function (_a) {
|
194
|
+
switch (_a.label) {
|
195
|
+
case 0:
|
196
|
+
if (!(response.status >= 200 && response.status < 300)) return [3 /*break*/, 2];
|
197
|
+
return [4 /*yield*/, response.data.d];
|
198
|
+
case 1: return [2 /*return*/, _a.sent()];
|
199
|
+
case 2: return [2 /*return*/, Promise.reject(new Error(JSON.stringify(response)))];
|
200
|
+
}
|
201
|
+
});
|
202
|
+
}); })
|
203
|
+
.then(function (data) { return __awaiter(_this, void 0, void 0, function () {
|
204
|
+
var i, item, returnItem;
|
205
|
+
return __generator(this, function (_a) {
|
206
|
+
switch (_a.label) {
|
207
|
+
case 0:
|
208
|
+
if (data.results) {
|
209
|
+
for (i = 0; i < data.results.length; i++) {
|
210
|
+
item = data.results[i];
|
211
|
+
items.push(item);
|
212
|
+
}
|
213
|
+
}
|
214
|
+
returnItem = {
|
215
|
+
__next: data.__next,
|
216
|
+
results: items,
|
217
|
+
};
|
218
|
+
if (!(returnItem.__next != undefined &&
|
219
|
+
returnItem.__next.length > 0 &&
|
220
|
+
recursiveCount < maxRecursiveCount)) return [3 /*break*/, 2];
|
221
|
+
return [4 /*yield*/, this.recursiveFetch(returnItem.__next, recursiveCount + 1, maxRecursiveCount, returnItem.results)];
|
222
|
+
case 1:
|
223
|
+
items = _a.sent();
|
224
|
+
_a.label = 2;
|
225
|
+
case 2: return [2 /*return*/];
|
226
|
+
}
|
227
|
+
});
|
228
|
+
}); })
|
229
|
+
.catch(function (ex) {
|
230
|
+
console.log("load Items > JitzSPHttpClient.get()...catch:", ex);
|
231
|
+
throw ex;
|
232
|
+
})];
|
233
|
+
case 1:
|
234
|
+
_a.sent();
|
235
|
+
return [2 /*return*/, items];
|
236
|
+
}
|
237
|
+
});
|
238
|
+
});
|
239
|
+
};
|
240
|
+
Repository.prototype.itemsCount = function (filters) {
|
241
|
+
var queryUrlGetAllItems = "".concat(this.context.siteUrl, "/_api/web/lists/GetByTitle('") +
|
242
|
+
this.listName +
|
243
|
+
"')/ItemCount";
|
244
|
+
if (filters != null && filters != "") {
|
245
|
+
queryUrlGetAllItems = queryUrlGetAllItems + "?$filter=" + filters;
|
246
|
+
}
|
247
|
+
return this.context.client
|
248
|
+
.get(queryUrlGetAllItems)
|
249
|
+
.then(function (response) {
|
250
|
+
if (response.status >= 200 && response.status < 300) {
|
251
|
+
// console.log(response);
|
252
|
+
return response.data.d.ItemCount;
|
253
|
+
}
|
254
|
+
else {
|
255
|
+
return Promise.reject(new Error(JSON.stringify(response)));
|
256
|
+
}
|
257
|
+
})
|
258
|
+
.then(function (data) {
|
259
|
+
return data;
|
260
|
+
})
|
261
|
+
.catch(function (ex) {
|
262
|
+
console.log("loadEvents > JitzSPHttpClient.get()...catch:", ex);
|
263
|
+
throw ex;
|
264
|
+
});
|
265
|
+
};
|
266
|
+
Repository.prototype.getItemById = function (id, selectFields, expand) {
|
267
|
+
return __awaiter(this, void 0, void 0, function () {
|
268
|
+
var queryUrl;
|
269
|
+
return __generator(this, function (_a) {
|
270
|
+
switch (_a.label) {
|
271
|
+
case 0:
|
272
|
+
queryUrl = "".concat(this.context.siteUrl, "/_api/web/lists/getByTitle('") +
|
273
|
+
this.listName +
|
274
|
+
"')/items(" +
|
275
|
+
id +
|
276
|
+
")" +
|
277
|
+
"?$select=*".concat(selectFields != undefined ? ",".concat(selectFields) : "") +
|
278
|
+
"".concat(expand != undefined ? "&$expand=".concat(expand) : "");
|
279
|
+
return [4 /*yield*/, this.context.client
|
280
|
+
.get(queryUrl)
|
281
|
+
.then(function (response) {
|
282
|
+
if (response.status >= 200 && response.status < 300) {
|
283
|
+
return response.data.d;
|
284
|
+
}
|
285
|
+
else {
|
286
|
+
return Promise.reject(new Error(JSON.stringify(response)));
|
287
|
+
}
|
288
|
+
})
|
289
|
+
.then(function (data) {
|
290
|
+
return data;
|
291
|
+
})
|
292
|
+
.catch(function (ex) {
|
293
|
+
console.log("loadEvents > JitzSPHttpClient.get()...catch:", ex);
|
294
|
+
throw ex;
|
295
|
+
})];
|
296
|
+
case 1: return [2 /*return*/, _a.sent()];
|
297
|
+
}
|
298
|
+
});
|
299
|
+
});
|
300
|
+
};
|
301
|
+
Repository.prototype.createItem = function (item) {
|
302
|
+
var _this = this;
|
303
|
+
return this.getEntityType().then(function (entityType) {
|
304
|
+
item.__metadata = {
|
305
|
+
type: entityType,
|
306
|
+
};
|
307
|
+
var requestUrl = "".concat(_this.context.siteUrl, "/_api/web/lists/getbytitle('").concat(_this.listName, "')/items");
|
308
|
+
return _this.context.client
|
309
|
+
.post(requestUrl, item, {
|
310
|
+
Accept: "application/json;odata=nometadata",
|
311
|
+
"Content-type": "application/json;odata=verbose",
|
312
|
+
"odata-version": "",
|
313
|
+
})
|
314
|
+
.then(function (response) {
|
315
|
+
if (response.status >= 200 && response.status < 300) {
|
316
|
+
var json = response;
|
317
|
+
return json;
|
318
|
+
}
|
319
|
+
else {
|
320
|
+
return Promise.reject(new Error(JSON.stringify(response)));
|
321
|
+
}
|
322
|
+
});
|
323
|
+
});
|
324
|
+
};
|
325
|
+
Repository.prototype.updateItem = function (item) {
|
326
|
+
var _this = this;
|
327
|
+
return this.getEntityType().then(function (entityType) {
|
328
|
+
item.__metadata = {
|
329
|
+
//etag: "1",
|
330
|
+
type: entityType,
|
331
|
+
};
|
332
|
+
var requestUrl = "".concat(_this.context.siteUrl, "/_api/web/lists/getbytitle('").concat(_this.listName, "')/items(").concat(item.Id, ")");
|
333
|
+
return _this.context.client
|
334
|
+
.post(requestUrl, item, {
|
335
|
+
Accept: "application/json;odata=nometadata",
|
336
|
+
"Content-type": "application/json;odata=verbose",
|
337
|
+
"odata-version": "",
|
338
|
+
"IF-MATCH": "*",
|
339
|
+
"X-HTTP-Method": "MERGE",
|
340
|
+
})
|
341
|
+
.then(function (response) {
|
342
|
+
if (response.status >= 200 && response.status < 300) {
|
343
|
+
return item;
|
344
|
+
}
|
345
|
+
else {
|
346
|
+
return Promise.reject(new Error(JSON.stringify(response)));
|
347
|
+
}
|
348
|
+
});
|
349
|
+
});
|
350
|
+
};
|
351
|
+
Repository.prototype.deleteItem = function (id) {
|
352
|
+
var requestUrl = "".concat(this.context.siteUrl, "/_api/web/lists/getbytitle('").concat(this.listName, "')/items(").concat(id, ")");
|
353
|
+
return this.context.client
|
354
|
+
.post(requestUrl, {}, {
|
355
|
+
Accept: "application/json;odata=nometadata",
|
356
|
+
"Content-type": "application/json;odata=verbose",
|
357
|
+
"odata-version": "",
|
358
|
+
"IF-MATCH": "*",
|
359
|
+
"X-HTTP-Method": "DELETE",
|
360
|
+
})
|
361
|
+
.then(function (response) {
|
362
|
+
if (response.status >= 200 && response.status < 300) {
|
363
|
+
return true;
|
364
|
+
}
|
365
|
+
else {
|
366
|
+
return Promise.reject(new Error(JSON.stringify(response)));
|
367
|
+
}
|
368
|
+
});
|
369
|
+
};
|
370
|
+
Repository.prototype.getEntityType = function () {
|
371
|
+
var _this = this;
|
372
|
+
return new Promise(function (resolve, reject) {
|
373
|
+
if (_this._listEntityType) {
|
374
|
+
resolve(_this._listEntityType);
|
375
|
+
return;
|
376
|
+
}
|
377
|
+
_this.context.client
|
378
|
+
.get("".concat(_this.context.siteUrl, "/_api/web/lists/getbytitle('").concat(_this.listName, "')?$select=ListItemEntityTypeFullName"))
|
379
|
+
.then(function (response) {
|
380
|
+
return response;
|
381
|
+
}, function (error) {
|
382
|
+
reject(error);
|
383
|
+
})
|
384
|
+
.then(function (response) {
|
385
|
+
_this._listEntityType = response.data.d.ListItemEntityTypeFullName;
|
386
|
+
resolve(_this._listEntityType || "");
|
387
|
+
});
|
388
|
+
});
|
389
|
+
};
|
390
|
+
return Repository;
|
391
|
+
}());
|
392
|
+
exports.default = Repository;
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { WebPartContext } from "@microsoft/sp-webpart-base";
|
2
|
+
export default class GraphService {
|
3
|
+
private _context;
|
4
|
+
private context;
|
5
|
+
private client;
|
6
|
+
constructor(_context: WebPartContext);
|
7
|
+
init(): Promise<void>;
|
8
|
+
getListItems(siteId: string): Promise<string>;
|
9
|
+
getUserId(userUPN: string): Promise<string>;
|
10
|
+
}
|
@@ -0,0 +1,103 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
15
|
+
function step(op) {
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
20
|
+
switch (op[0]) {
|
21
|
+
case 0: case 1: t = op; break;
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
25
|
+
default:
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
30
|
+
if (t[2]) _.ops.pop();
|
31
|
+
_.trys.pop(); continue;
|
32
|
+
}
|
33
|
+
op = body.call(thisArg, _);
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
36
|
+
}
|
37
|
+
};
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
39
|
+
var GraphService = /** @class */ (function () {
|
40
|
+
function GraphService(_context) {
|
41
|
+
this._context = _context;
|
42
|
+
this.context = _context;
|
43
|
+
}
|
44
|
+
GraphService.prototype.init = function () {
|
45
|
+
return __awaiter(this, void 0, void 0, function () {
|
46
|
+
var _this = this;
|
47
|
+
return __generator(this, function (_a) {
|
48
|
+
switch (_a.label) {
|
49
|
+
case 0: return [4 /*yield*/, this.context.msGraphClientFactory
|
50
|
+
.getClient("3") // Init Microsoft Graph Client
|
51
|
+
.then(function (client) {
|
52
|
+
_this.client = client;
|
53
|
+
})];
|
54
|
+
case 1:
|
55
|
+
_a.sent();
|
56
|
+
return [2 /*return*/];
|
57
|
+
}
|
58
|
+
});
|
59
|
+
});
|
60
|
+
};
|
61
|
+
GraphService.prototype.getListItems = function (siteId) {
|
62
|
+
return __awaiter(this, void 0, void 0, function () {
|
63
|
+
return __generator(this, function (_a) {
|
64
|
+
switch (_a.label) {
|
65
|
+
case 0: return [4 /*yield*/, this.client
|
66
|
+
.api("/sites/".concat(siteId, "/lists/f2991442-109b-4778-845b-6e11b1d6fed9/items?expand=fields($select=TicketCategory,TicketCategoryLookupId)&top=1")) //Get Presence method
|
67
|
+
.version("beta") // Beta version
|
68
|
+
// .select("id") // Select only ID attribute
|
69
|
+
.get(function (err, res) {
|
70
|
+
if (err) {
|
71
|
+
console.log(err);
|
72
|
+
return err;
|
73
|
+
}
|
74
|
+
return res;
|
75
|
+
})];
|
76
|
+
case 1: return [2 /*return*/, _a.sent()];
|
77
|
+
}
|
78
|
+
});
|
79
|
+
});
|
80
|
+
};
|
81
|
+
GraphService.prototype.getUserId = function (userUPN) {
|
82
|
+
return __awaiter(this, void 0, void 0, function () {
|
83
|
+
return __generator(this, function (_a) {
|
84
|
+
switch (_a.label) {
|
85
|
+
case 0: return [4 /*yield*/, this.client
|
86
|
+
.api("users/".concat(userUPN)) //Get Presence method
|
87
|
+
.version("beta") // Beta version
|
88
|
+
.select("id") // Select only ID attribute
|
89
|
+
.get(function (err, res) {
|
90
|
+
if (err) {
|
91
|
+
console.log(err);
|
92
|
+
return err;
|
93
|
+
}
|
94
|
+
return res;
|
95
|
+
})];
|
96
|
+
case 1: return [2 /*return*/, _a.sent()];
|
97
|
+
}
|
98
|
+
});
|
99
|
+
});
|
100
|
+
};
|
101
|
+
return GraphService;
|
102
|
+
}());
|
103
|
+
exports.default = GraphService;
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { IPersonOrGroup } from "../common/IModels";
|
2
|
+
import { IJitzSPContext } from "../jitzSPHttpClient";
|
3
|
+
export default class UserService {
|
4
|
+
private _context;
|
5
|
+
private _webAbsoluteUrl;
|
6
|
+
constructor(context: IJitzSPContext);
|
7
|
+
getCurrentUser: () => any;
|
8
|
+
getUserProperties: (accountName: string) => Promise<any>;
|
9
|
+
getUserPropertiesByEmail: (email: string) => Promise<any>;
|
10
|
+
getCurrentUserGroups(): Promise<IPersonOrGroup[]>;
|
11
|
+
checkIfCurrentUserInGroup(groupName: string): Promise<boolean>;
|
12
|
+
checkIfUserIsInGroup(userId: number, groupName: string): Promise<boolean>;
|
13
|
+
getUserById: (id: number) => any;
|
14
|
+
getCurrentUserPermissions: () => any;
|
15
|
+
}
|