jitz-sharepoint-utilities 2.0.12 → 2.0.14

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.
Files changed (59) hide show
  1. package/package.json +1 -1
  2. package/lib/common/IModels.d.ts +0 -40
  3. package/lib/common/IModels.js +0 -2
  4. package/lib/common/IObjects.d.ts +0 -72
  5. package/lib/common/IObjects.js +0 -30
  6. package/lib/controls/JitzGrid.d.ts +0 -75
  7. package/lib/controls/JitzGrid.js +0 -606
  8. package/lib/controls/JitzImage.d.ts +0 -14
  9. package/lib/controls/JitzImage.js +0 -37
  10. package/lib/controls/JitzPeoplePicker.d.ts +0 -49
  11. package/lib/controls/JitzPeoplePicker.js +0 -311
  12. package/lib/controls/JitzPersonInfo.d.ts +0 -32
  13. package/lib/controls/JitzPersonInfo.js +0 -98
  14. package/lib/controls/JitzPersona.d.ts +0 -23
  15. package/lib/controls/JitzPersona.js +0 -48
  16. package/lib/data/context/CommonRepository.d.ts +0 -17
  17. package/lib/data/context/CommonRepository.js +0 -287
  18. package/lib/data/context/JitzContext.d.ts +0 -13
  19. package/lib/data/context/JitzContext.js +0 -80
  20. package/lib/data/context/JitzSPContext.d.ts +0 -8
  21. package/lib/data/context/JitzSPContext.js +0 -58
  22. package/lib/data/context/JitzSPHttpClient.d.ts +0 -14
  23. package/lib/data/context/JitzSPHttpClient.js +0 -173
  24. package/lib/data/context/List.d.ts +0 -39
  25. package/lib/data/context/List.js +0 -492
  26. package/lib/data/context/Repository.d.ts +0 -22
  27. package/lib/data/context/Repository.js +0 -486
  28. package/lib/data/interfaces/ICommonRepository.d.ts +0 -6
  29. package/lib/data/interfaces/ICommonRepository.js +0 -2
  30. package/lib/data/interfaces/IJitzContext.d.ts +0 -10
  31. package/lib/data/interfaces/IJitzContext.js +0 -2
  32. package/lib/data/interfaces/IJitzSPContext.d.ts +0 -6
  33. package/lib/data/interfaces/IJitzSPContext.js +0 -2
  34. package/lib/data/interfaces/IJitzSPHttpClient.d.ts +0 -6
  35. package/lib/data/interfaces/IJitzSPHttpClient.js +0 -2
  36. package/lib/data/interfaces/IList.d.ts +0 -26
  37. package/lib/data/interfaces/IList.js +0 -2
  38. package/lib/data/interfaces/IModels.d.ts +0 -32
  39. package/lib/data/interfaces/IModels.js +0 -2
  40. package/lib/data/interfaces/IRepository.d.ts +0 -17
  41. package/lib/data/interfaces/IRepository.js +0 -2
  42. package/lib/jitzHttpClient.d.ts +0 -11
  43. package/lib/jitzHttpClient.js +0 -37
  44. package/lib/jitzSPHttpClient.d.ts +0 -30
  45. package/lib/jitzSPHttpClient.js +0 -193
  46. package/lib/repositories/CommonRepository.d.ts +0 -17
  47. package/lib/repositories/CommonRepository.js +0 -288
  48. package/lib/repositories/ICommonRepository.d.ts +0 -6
  49. package/lib/repositories/ICommonRepository.js +0 -2
  50. package/lib/repositories/IRepository.d.ts +0 -13
  51. package/lib/repositories/IRepository.js +0 -2
  52. package/lib/repositories/Repository.d.ts +0 -18
  53. package/lib/repositories/Repository.js +0 -394
  54. package/lib/services/GraphService.d.ts +0 -10
  55. package/lib/services/GraphService.js +0 -105
  56. package/lib/services/UserService.d.ts +0 -15
  57. package/lib/services/UserService.js +0 -202
  58. package/lib/services/UtilityService.d.ts +0 -29
  59. package/lib/services/UtilityService.js +0 -254
@@ -1,287 +0,0 @@
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 CommonRepository = /** @class */ (function () {
40
- function CommonRepository(context) {
41
- this.context = context;
42
- }
43
- CommonRepository.prototype.sendEmail = function (email) {
44
- email.properties.__metadata = {
45
- type: "SP.Utilities.EmailProperties",
46
- };
47
- // console.log(JSON.stringify(email.properties));
48
- var requestUrl = "".concat(this.context.siteUrl, "/_api/SP.Utilities.Utility.SendEmail");
49
- return this.context.client
50
- .post(requestUrl, email, {
51
- Accept: "application/json;odata=nometadata",
52
- "Content-type": "application/json;odata=verbose",
53
- "odata-version": "",
54
- })
55
- .then(function (response) {
56
- if (response.status >= 200 && response.status < 300) {
57
- var json = response;
58
- return json;
59
- }
60
- else {
61
- return Promise.reject(new Error(JSON.stringify(response)));
62
- }
63
- });
64
- };
65
- CommonRepository.prototype.getData = function (listName, selectFields, expand, filters, orderBy, top, skipTokenUniqueField, skipTokenUniqueFieldValue) {
66
- var queryUrlGetAllItems = "/_api/web/lists/GetByTitle('" + listName + "')/items";
67
- if (selectFields != null && selectFields != "") {
68
- queryUrlGetAllItems = queryUrlGetAllItems + "?$select=" + selectFields;
69
- }
70
- else {
71
- queryUrlGetAllItems = queryUrlGetAllItems + "?$select=*";
72
- }
73
- if (expand != null && expand != "") {
74
- queryUrlGetAllItems = queryUrlGetAllItems + "&$expand=" + expand;
75
- }
76
- if (top != null && top != undefined && top > 0) {
77
- queryUrlGetAllItems = queryUrlGetAllItems + "&$top=" + top;
78
- }
79
- if (filters != null && filters != "") {
80
- queryUrlGetAllItems = queryUrlGetAllItems + "&$filter=" + filters;
81
- }
82
- if (orderBy != null && orderBy != "") {
83
- queryUrlGetAllItems = queryUrlGetAllItems + "&$orderby=" + orderBy;
84
- }
85
- if (skipTokenUniqueField != null &&
86
- skipTokenUniqueField != undefined &&
87
- skipTokenUniqueFieldValue != null &&
88
- skipTokenUniqueFieldValue != undefined) {
89
- if (skipTokenUniqueField == "Id" || skipTokenUniqueField == "id") {
90
- skipTokenUniqueField = "ID";
91
- }
92
- queryUrlGetAllItems =
93
- queryUrlGetAllItems +
94
- "&$skiptoken=Paged=TRUE%26p_".concat(skipTokenUniqueField, "=").concat(skipTokenUniqueFieldValue);
95
- }
96
- return this.context.client
97
- .get(queryUrlGetAllItems)
98
- .then(function (response) {
99
- if (response.status >= 200 && response.status < 300) {
100
- return response.data.d;
101
- }
102
- else {
103
- return Promise.reject(new Error(JSON.stringify(response)));
104
- }
105
- })
106
- .then(function (data) {
107
- return data;
108
- })
109
- .catch(function (ex) {
110
- console.log("load Items > JitzSPHttpClient.get()...catch:", ex);
111
- throw ex;
112
- });
113
- };
114
- CommonRepository.prototype.get = function (url) {
115
- return this.context.client
116
- .get(url)
117
- .then(function (response) {
118
- if (response.status >= 200 && response.status < 300) {
119
- return response.data.d;
120
- }
121
- else {
122
- return Promise.reject(new Error(JSON.stringify(response)));
123
- }
124
- })
125
- .then(function (data) {
126
- return data;
127
- })
128
- .catch(function (ex) {
129
- console.log("load Items > JitzSPHttpClient.get()...catch:", ex);
130
- throw ex;
131
- });
132
- };
133
- CommonRepository.prototype.post = function (url, data, header) {
134
- return this.context.client
135
- .post(url, data, header)
136
- .then(function (response) {
137
- if (response.status >= 200 && response.status < 300) {
138
- return response.data;
139
- }
140
- else {
141
- return Promise.reject(new Error(JSON.stringify(response)));
142
- }
143
- })
144
- .then(function (data) {
145
- return data;
146
- })
147
- .catch(function (ex) {
148
- console.log("load Items > JitzSPHttpClient.get()...catch:", ex);
149
- throw ex;
150
- });
151
- };
152
- CommonRepository.prototype.getFiles = function (libraryName, selectFields, filter, expandFields) {
153
- var url = "/_api/web/lists/getbytitle('".concat(libraryName, "')/Items?$select=*,File/Name,File/ServerRelativeUrl");
154
- if (selectFields != undefined && selectFields.length > 0) {
155
- url = "".concat(url, ",").concat(selectFields);
156
- }
157
- if (filter != undefined && filter.length > 0) {
158
- url = "".concat(url, "&$filter=").concat(filter);
159
- }
160
- url = "".concat(url, "&$expand=File");
161
- if (expandFields != undefined && expandFields.length > 0) {
162
- url = "".concat(url, ",").concat(expandFields);
163
- }
164
- return this.context.client.get(url).then(function (response) {
165
- if (response.status >= 200 && response.status <= 300) {
166
- var json = response.data.d.results;
167
- return json;
168
- }
169
- else {
170
- return Promise.reject(new Error(JSON.stringify(response)));
171
- }
172
- });
173
- };
174
- CommonRepository.prototype.uploadFile = function (libraryName, fileName, arrayBuffer) {
175
- return this.context.client
176
- .postWithOutStringify("/_api/Web/Lists/getByTitle('".concat(libraryName, "')/RootFolder/Files/Add(url='").concat(fileName, "', overwrite=true)"), arrayBuffer, {
177
- Accept: "application/json;odata=verbose",
178
- "content-length": arrayBuffer.byteLength.toString(),
179
- })
180
- .then(function (response) {
181
- if (response.status >= 200 && response.status <= 300) {
182
- var json = response.data.d;
183
- return json;
184
- }
185
- else {
186
- return Promise.reject(new Error(JSON.stringify(response)));
187
- }
188
- });
189
- };
190
- CommonRepository.prototype.getFileItem = function (libraryName, fileUrl) {
191
- // `${this._webAbsoluteUrl}/_api/web/GetFileByServerRelativeUrl('${fileUrl}')/$value`
192
- return this.context.client
193
- .get("/_api/web/lists/getbytitle('".concat(libraryName, "')/Items?$filter=FileLeafRef eq '").concat(fileUrl, "'&$select=Id"))
194
- .then(function (response) {
195
- if (response.status >= 200 && response.status <= 300) {
196
- var json = response.data.d;
197
- return json;
198
- }
199
- else {
200
- return Promise.reject(new Error(JSON.stringify(response)));
201
- }
202
- });
203
- };
204
- CommonRepository.prototype.updateMetadata = function (listName, item) {
205
- return __awaiter(this, void 0, void 0, function () {
206
- var url;
207
- var _this = this;
208
- return __generator(this, function (_a) {
209
- switch (_a.label) {
210
- case 0: return [4 /*yield*/, this.getEntityType(listName).then(function (entityType) {
211
- item.__metadata = {
212
- //etag: "1",
213
- type: entityType,
214
- };
215
- var requestUrl = "_api/web/lists/getbytitle('".concat(listName, "')/items(").concat(item.Id, ")");
216
- return _this.context.client
217
- .post(requestUrl, item, {
218
- Accept: "application/json;odata=nometadata",
219
- "Content-type": "application/json;odata=verbose",
220
- "odata-version": "",
221
- "IF-MATCH": "*",
222
- "X-HTTP-Method": "MERGE",
223
- })
224
- .then(function (response) {
225
- if (response.status >= 200 && response.status < 300) {
226
- return item;
227
- }
228
- else {
229
- console.log(JSON.stringify(response));
230
- return Promise.reject(new Error(JSON.stringify(response)));
231
- }
232
- });
233
- })];
234
- case 1:
235
- _a.sent();
236
- url = "/_api/web/lists/getbytitle('".concat(listName, "')/items(").concat(item.Id, ")?$select=*,File/Name,File/ServerRelativeUrl&$expand=File");
237
- return [2 /*return*/, this.context.client.get(url).then(function (response) {
238
- if (response.status >= 200 && response.status <= 300) {
239
- var json = response.data.d;
240
- return json;
241
- }
242
- else {
243
- return Promise.reject(new Error(JSON.stringify(response)));
244
- }
245
- })];
246
- }
247
- });
248
- });
249
- };
250
- CommonRepository.prototype.deleteFile = function (listName, id) {
251
- var requestUrl = "_api/web/lists/getbytitle('".concat(listName, "')/items(").concat(id, ")");
252
- return this.context.client
253
- .post(requestUrl, {}, {
254
- Accept: "application/json;odata=nometadata",
255
- "Content-type": "application/json;odata=verbose",
256
- "odata-version": "",
257
- "IF-MATCH": "*",
258
- "X-HTTP-Method": "DELETE",
259
- })
260
- .then(function (response) {
261
- if (response.status >= 200 && response.status < 300) {
262
- return true;
263
- }
264
- else {
265
- return Promise.reject(new Error(JSON.stringify(response)));
266
- }
267
- });
268
- };
269
- CommonRepository.prototype.getEntityType = function (listName) {
270
- var _this = this;
271
- return new Promise(function (resolve, reject) {
272
- _this.context.client
273
- .get("_api/web/lists/getbytitle('".concat(listName, "')?$select=ListItemEntityTypeFullName"))
274
- .then(function (response) {
275
- return response;
276
- }, function (error) {
277
- reject(error);
278
- })
279
- .then(function (response) {
280
- var _listEntityType = response.data.d.ListItemEntityTypeFullName;
281
- resolve(_listEntityType || "");
282
- });
283
- });
284
- };
285
- return CommonRepository;
286
- }());
287
- exports.default = CommonRepository;
@@ -1,13 +0,0 @@
1
- import { WebPartContext } from "@microsoft/sp-webpart-base";
2
- import { MSGraphClientV3 } from "@microsoft/sp-http";
3
- import IJitzContext from "../interfaces/IJitzContext";
4
- import IJitzSPContext from "../interfaces/IJitzSPContext";
5
- export default class JitzContext implements IJitzContext {
6
- spContext: IJitzSPContext;
7
- webpartContext: WebPartContext;
8
- graphClient: MSGraphClientV3;
9
- siteId: string;
10
- constructor(webpartContext: WebPartContext);
11
- init(): Promise<void>;
12
- private initGraphClient;
13
- }
@@ -1,80 +0,0 @@
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 JitzSPContext_1 = require("./JitzSPContext");
40
- var JitzContext = /** @class */ (function () {
41
- function JitzContext(webpartContext) {
42
- this.spContext = new JitzSPContext_1.default(webpartContext.pageContext.site.absoluteUrl);
43
- this.webpartContext = webpartContext;
44
- this.siteId = this.webpartContext.pageContext.site.id.toString();
45
- }
46
- JitzContext.prototype.init = function () {
47
- return __awaiter(this, void 0, void 0, function () {
48
- return __generator(this, function (_a) {
49
- switch (_a.label) {
50
- case 0: return [4 /*yield*/, this.spContext.init()];
51
- case 1:
52
- _a.sent();
53
- return [4 /*yield*/, this.initGraphClient()];
54
- case 2:
55
- _a.sent();
56
- return [2 /*return*/];
57
- }
58
- });
59
- });
60
- };
61
- JitzContext.prototype.initGraphClient = function () {
62
- return __awaiter(this, void 0, void 0, function () {
63
- var _this = this;
64
- return __generator(this, function (_a) {
65
- switch (_a.label) {
66
- case 0: return [4 /*yield*/, this.webpartContext.msGraphClientFactory
67
- .getClient("3") // Init Microsoft Graph Client
68
- .then(function (client) {
69
- _this.graphClient = client;
70
- })];
71
- case 1:
72
- _a.sent();
73
- return [2 /*return*/];
74
- }
75
- });
76
- });
77
- };
78
- return JitzContext;
79
- }());
80
- exports.default = JitzContext;
@@ -1,8 +0,0 @@
1
- import IJitzSPContext from "../interfaces/IJitzSPContext";
2
- import IJitzSPHttpClient from "../interfaces/IJitzSPHttpClient";
3
- export default class JitzSPContext implements IJitzSPContext {
4
- client: IJitzSPHttpClient;
5
- siteUrl: string;
6
- constructor(siteUrl: string);
7
- init: () => Promise<void>;
8
- }
@@ -1,58 +0,0 @@
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 JitzSPHttpClient_1 = require("./JitzSPHttpClient");
40
- var JitzSPContext = /** @class */ (function () {
41
- function JitzSPContext(siteUrl) {
42
- var _this = this;
43
- this.init = function () { return __awaiter(_this, void 0, void 0, function () {
44
- return __generator(this, function (_a) {
45
- switch (_a.label) {
46
- case 0: return [4 /*yield*/, this.client.init()];
47
- case 1:
48
- _a.sent();
49
- return [2 /*return*/];
50
- }
51
- });
52
- }); };
53
- this.siteUrl = siteUrl;
54
- this.client = new JitzSPHttpClient_1.default(siteUrl);
55
- }
56
- return JitzSPContext;
57
- }());
58
- exports.default = JitzSPContext;
@@ -1,14 +0,0 @@
1
- import IJitzSPHttpClient from "../interfaces/IJitzSPHttpClient";
2
- export default class JitzSPHttpClient implements IJitzSPHttpClient {
3
- siteUrl: string;
4
- client: any;
5
- securityToken: string;
6
- private header;
7
- constructor(siteUrl?: string);
8
- init: () => Promise<void>;
9
- get: (url: string, header?: any) => any;
10
- post: (url: string, data: any, header?: any) => any;
11
- postWithOutStringify: (url: string, data: any, header?: any) => any;
12
- getSecurityValidation: () => any;
13
- refreshSecurityValidation: () => Promise<void>;
14
- }
@@ -1,173 +0,0 @@
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 axios_1 = require("axios");
40
- var JitzSPHttpClient = /** @class */ (function () {
41
- function JitzSPHttpClient(siteUrl) {
42
- if (siteUrl === void 0) { siteUrl = ""; }
43
- var _this = this;
44
- this.securityToken = "";
45
- this.header = {
46
- Accept: "application/json;odata=verbose",
47
- "Content-Type": "application/json;odata=verbose",
48
- };
49
- this.init = function () { return __awaiter(_this, void 0, void 0, function () {
50
- return __generator(this, function (_a) {
51
- switch (_a.label) {
52
- case 0: return [4 /*yield*/, this.refreshSecurityValidation()];
53
- case 1:
54
- _a.sent();
55
- return [2 /*return*/];
56
- }
57
- });
58
- }); };
59
- this.get = function (url, header) {
60
- header = header || _this.header;
61
- header["X-RequestDigest"] = _this.securityToken;
62
- var authOptions = {
63
- method: "GET",
64
- url: url,
65
- data: JSON.stringify({}),
66
- headers: header,
67
- json: true,
68
- };
69
- return _this.client(authOptions);
70
- // return this.getSecurityValidation().then((ctx: any) => {
71
- // this.securityToken = ctx.data.d.GetContextWebInformation.FormDigestValue;
72
- // header["X-RequestDigest"] = this.securityToken;
73
- // var authOptions = {
74
- // method: "GET",
75
- // url: url,
76
- // data: JSON.stringify({}),
77
- // headers: header,
78
- // json: true,
79
- // };
80
- // return this.client(authOptions);
81
- // });
82
- };
83
- this.post = function (url, data, header) {
84
- header = header || _this.header;
85
- header["X-RequestDigest"] = _this.securityToken;
86
- header["Accept"] = "application/json;odata=verbose";
87
- header["Content-Type"] = "application/json;odata=verbose";
88
- var authOptions = {
89
- method: "POST",
90
- url: url,
91
- data: JSON.stringify(data),
92
- headers: header,
93
- json: true,
94
- };
95
- return _this.client(authOptions);
96
- // return this.getSecurityValidation().then((ctx: any) => {
97
- // this.securityToken = ctx.data.d.GetContextWebInformation.FormDigestValue;
98
- // header["X-RequestDigest"] = this.securityToken;
99
- // var authOptions = {
100
- // method: "POST",
101
- // url: url,
102
- // data: JSON.stringify(data),
103
- // headers: header,
104
- // json: true,
105
- // };
106
- // return this.client(authOptions);
107
- // });
108
- };
109
- this.postWithOutStringify = function (url, data, header) {
110
- header = header || _this.header;
111
- header["X-RequestDigest"] = _this.securityToken;
112
- var authOptions = {
113
- method: "POST",
114
- url: url,
115
- data: data,
116
- headers: header,
117
- json: true,
118
- };
119
- return _this.client(authOptions);
120
- };
121
- this.getSecurityValidation = function () {
122
- var authOptions = {
123
- method: "POST",
124
- url: "/_api/contextinfo",
125
- data: JSON.stringify({}),
126
- headers: {
127
- Accept: "application/json;odata=verbose",
128
- "Content-Type": "application/json;odata=verbose",
129
- },
130
- json: true,
131
- };
132
- return _this.client(authOptions);
133
- };
134
- this.refreshSecurityValidation = function () { return __awaiter(_this, void 0, void 0, function () {
135
- var authOptions;
136
- var _this = this;
137
- return __generator(this, function (_a) {
138
- switch (_a.label) {
139
- case 0:
140
- authOptions = {
141
- method: "POST",
142
- url: "/_api/contextinfo",
143
- data: JSON.stringify({}),
144
- headers: {
145
- Accept: "application/json;odata=verbose",
146
- "Content-Type": "application/json;odata=verbose",
147
- },
148
- json: true,
149
- };
150
- return [4 /*yield*/, this.client(authOptions).then(function (context) {
151
- _this.securityToken =
152
- context.data.d.GetContextWebInformation.FormDigestValue;
153
- // console.log("Token:- "+this.securityToken);
154
- var interval = setInterval(function () {
155
- _this.refreshSecurityValidation();
156
- clearInterval(interval);
157
- }, 600000); //300000
158
- })];
159
- case 1:
160
- _a.sent();
161
- return [2 /*return*/];
162
- }
163
- });
164
- }); };
165
- this.siteUrl = siteUrl;
166
- this.securityToken = "";
167
- this.client = axios_1.default.create({
168
- baseURL: this.siteUrl,
169
- });
170
- }
171
- return JitzSPHttpClient;
172
- }());
173
- exports.default = JitzSPHttpClient;