jitz-sharepoint-utilities 1.10.65 → 1.11.0
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/README.md +109 -109
- package/jitzHttpClient.ts +44 -44
- package/jitzSPHttpClient.ts +158 -158
- package/lib/common/IModels.d.ts +32 -32
- package/lib/common/IModels.js +2 -2
- package/lib/jitzHttpClient.d.ts +11 -11
- package/lib/jitzHttpClient.js +37 -37
- package/lib/jitzSPHttpClient.d.ts +30 -30
- package/lib/jitzSPHttpClient.js +191 -191
- package/lib/repositories/CommonRepository.d.ts +17 -16
- package/lib/repositories/CommonRepository.js +232 -213
- package/lib/repositories/ICommonRepository.d.ts +6 -6
- package/lib/repositories/ICommonRepository.js +2 -2
- package/lib/repositories/IRepository.d.ts +13 -13
- package/lib/repositories/IRepository.js +2 -2
- package/lib/repositories/Repository.d.ts +18 -18
- package/lib/repositories/Repository.js +392 -386
- package/lib/services/UserService.d.ts +15 -15
- package/lib/services/UserService.js +202 -202
- package/lib/services/UtilityService.d.ts +22 -22
- package/lib/services/UtilityService.js +149 -149
- package/package.json +2 -1
package/lib/common/IModels.d.ts
CHANGED
@@ -1,32 +1,32 @@
|
|
1
|
-
export interface IModel {
|
2
|
-
Id: number;
|
3
|
-
Title?: string;
|
4
|
-
AuthorId?: number;
|
5
|
-
Author?: IPersonOrGroup;
|
6
|
-
__metadata?: {};
|
7
|
-
}
|
8
|
-
export interface IListItemsMetadata<T> {
|
9
|
-
__next: string;
|
10
|
-
results: T[];
|
11
|
-
}
|
12
|
-
export interface IEmail {
|
13
|
-
properties: {
|
14
|
-
From?: string;
|
15
|
-
To: {
|
16
|
-
results: string[];
|
17
|
-
};
|
18
|
-
Body: string;
|
19
|
-
Subject: string;
|
20
|
-
__metadata?: {};
|
21
|
-
};
|
22
|
-
}
|
23
|
-
export interface IPersonOrGroup {
|
24
|
-
Id: number;
|
25
|
-
Title: string;
|
26
|
-
EMail: string;
|
27
|
-
Email: string;
|
28
|
-
Name: string;
|
29
|
-
LoginName: string;
|
30
|
-
IsGroup: boolean;
|
31
|
-
Groups?: IPersonOrGroup[];
|
32
|
-
}
|
1
|
+
export interface IModel {
|
2
|
+
Id: number;
|
3
|
+
Title?: string;
|
4
|
+
AuthorId?: number;
|
5
|
+
Author?: IPersonOrGroup;
|
6
|
+
__metadata?: {};
|
7
|
+
}
|
8
|
+
export interface IListItemsMetadata<T> {
|
9
|
+
__next: string;
|
10
|
+
results: T[];
|
11
|
+
}
|
12
|
+
export interface IEmail {
|
13
|
+
properties: {
|
14
|
+
From?: string;
|
15
|
+
To: {
|
16
|
+
results: string[];
|
17
|
+
};
|
18
|
+
Body: string;
|
19
|
+
Subject: string;
|
20
|
+
__metadata?: {};
|
21
|
+
};
|
22
|
+
}
|
23
|
+
export interface IPersonOrGroup {
|
24
|
+
Id: number;
|
25
|
+
Title: string;
|
26
|
+
EMail: string;
|
27
|
+
Email: string;
|
28
|
+
Name: string;
|
29
|
+
LoginName: string;
|
30
|
+
IsGroup: boolean;
|
31
|
+
Groups?: IPersonOrGroup[];
|
32
|
+
}
|
package/lib/common/IModels.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/lib/jitzHttpClient.d.ts
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
export interface IJitzHttpClient {
|
2
|
-
get: (url: string, header?: any) => any;
|
3
|
-
post: (url: string, data: any, header?: any) => any;
|
4
|
-
}
|
5
|
-
export default class JitzHttpClient implements IJitzHttpClient {
|
6
|
-
private header;
|
7
|
-
private _client;
|
8
|
-
constructor();
|
9
|
-
get: (url: string, header?: any) => any;
|
10
|
-
post: (url: string, data: any, header?: any) => any;
|
11
|
-
}
|
1
|
+
export interface IJitzHttpClient {
|
2
|
+
get: (url: string, header?: any) => any;
|
3
|
+
post: (url: string, data: any, header?: any) => any;
|
4
|
+
}
|
5
|
+
export default class JitzHttpClient implements IJitzHttpClient {
|
6
|
+
private header;
|
7
|
+
private _client;
|
8
|
+
constructor();
|
9
|
+
get: (url: string, header?: any) => any;
|
10
|
+
post: (url: string, data: any, header?: any) => any;
|
11
|
+
}
|
package/lib/jitzHttpClient.js
CHANGED
@@ -1,37 +1,37 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
var axios_1 = require("axios");
|
4
|
-
var JitzHttpClient = /** @class */ (function () {
|
5
|
-
function JitzHttpClient() {
|
6
|
-
var _this = this;
|
7
|
-
this.header = {
|
8
|
-
Accept: "application/json;odata=verbose",
|
9
|
-
"Content-Type": "application/json;odata=verbose",
|
10
|
-
};
|
11
|
-
this.get = function (url, header) {
|
12
|
-
header = header || _this.header;
|
13
|
-
var authOptions = {
|
14
|
-
method: "GET",
|
15
|
-
url: url,
|
16
|
-
data: JSON.stringify({}),
|
17
|
-
headers: header,
|
18
|
-
json: true,
|
19
|
-
};
|
20
|
-
return _this._client(authOptions);
|
21
|
-
};
|
22
|
-
this.post = function (url, data, header) {
|
23
|
-
header = header || _this.header;
|
24
|
-
var authOptions = {
|
25
|
-
method: "POST",
|
26
|
-
url: url,
|
27
|
-
data: JSON.stringify(data),
|
28
|
-
headers: header,
|
29
|
-
json: true,
|
30
|
-
};
|
31
|
-
return _this._client(authOptions);
|
32
|
-
};
|
33
|
-
this._client = axios_1.default.create({});
|
34
|
-
}
|
35
|
-
return JitzHttpClient;
|
36
|
-
}());
|
37
|
-
exports.default = JitzHttpClient;
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
var axios_1 = require("axios");
|
4
|
+
var JitzHttpClient = /** @class */ (function () {
|
5
|
+
function JitzHttpClient() {
|
6
|
+
var _this = this;
|
7
|
+
this.header = {
|
8
|
+
Accept: "application/json;odata=verbose",
|
9
|
+
"Content-Type": "application/json;odata=verbose",
|
10
|
+
};
|
11
|
+
this.get = function (url, header) {
|
12
|
+
header = header || _this.header;
|
13
|
+
var authOptions = {
|
14
|
+
method: "GET",
|
15
|
+
url: url,
|
16
|
+
data: JSON.stringify({}),
|
17
|
+
headers: header,
|
18
|
+
json: true,
|
19
|
+
};
|
20
|
+
return _this._client(authOptions);
|
21
|
+
};
|
22
|
+
this.post = function (url, data, header) {
|
23
|
+
header = header || _this.header;
|
24
|
+
var authOptions = {
|
25
|
+
method: "POST",
|
26
|
+
url: url,
|
27
|
+
data: JSON.stringify(data),
|
28
|
+
headers: header,
|
29
|
+
json: true,
|
30
|
+
};
|
31
|
+
return _this._client(authOptions);
|
32
|
+
};
|
33
|
+
this._client = axios_1.default.create({});
|
34
|
+
}
|
35
|
+
return JitzHttpClient;
|
36
|
+
}());
|
37
|
+
exports.default = JitzHttpClient;
|
@@ -1,30 +1,30 @@
|
|
1
|
-
export interface IJitzSPContext {
|
2
|
-
client: IJitzSPHttpClient;
|
3
|
-
siteUrl: string;
|
4
|
-
init: () => void;
|
5
|
-
}
|
6
|
-
export declare class JitzSPContext implements IJitzSPContext {
|
7
|
-
client: IJitzSPHttpClient;
|
8
|
-
siteUrl: string;
|
9
|
-
constructor(siteUrl: string);
|
10
|
-
init: () => Promise<void>;
|
11
|
-
}
|
12
|
-
export interface IJitzSPHttpClient {
|
13
|
-
init: () => void;
|
14
|
-
get: (url: string, header?: any) => any;
|
15
|
-
post: (url: string, data: any, header?: any) => any;
|
16
|
-
postWithOutStringify: (url: string, data: any, header?: any) => any;
|
17
|
-
}
|
18
|
-
export default class JitzSPHttpClient implements IJitzSPHttpClient {
|
19
|
-
siteUrl: string;
|
20
|
-
client: any;
|
21
|
-
securityToken: string;
|
22
|
-
private header;
|
23
|
-
constructor(siteUrl?: string);
|
24
|
-
init: () => Promise<void>;
|
25
|
-
get: (url: string, header?: any) => any;
|
26
|
-
post: (url: string, data: any, header?: any) => any;
|
27
|
-
postWithOutStringify: (url: string, data: any, header?: any) => any;
|
28
|
-
getSecurityValidation: () => any;
|
29
|
-
refreshSecurityValidation: () => Promise<void>;
|
30
|
-
}
|
1
|
+
export interface IJitzSPContext {
|
2
|
+
client: IJitzSPHttpClient;
|
3
|
+
siteUrl: string;
|
4
|
+
init: () => void;
|
5
|
+
}
|
6
|
+
export declare class JitzSPContext implements IJitzSPContext {
|
7
|
+
client: IJitzSPHttpClient;
|
8
|
+
siteUrl: string;
|
9
|
+
constructor(siteUrl: string);
|
10
|
+
init: () => Promise<void>;
|
11
|
+
}
|
12
|
+
export interface IJitzSPHttpClient {
|
13
|
+
init: () => void;
|
14
|
+
get: (url: string, header?: any) => any;
|
15
|
+
post: (url: string, data: any, header?: any) => any;
|
16
|
+
postWithOutStringify: (url: string, data: any, header?: any) => any;
|
17
|
+
}
|
18
|
+
export default class JitzSPHttpClient implements IJitzSPHttpClient {
|
19
|
+
siteUrl: string;
|
20
|
+
client: any;
|
21
|
+
securityToken: string;
|
22
|
+
private header;
|
23
|
+
constructor(siteUrl?: string);
|
24
|
+
init: () => Promise<void>;
|
25
|
+
get: (url: string, header?: any) => any;
|
26
|
+
post: (url: string, data: any, header?: any) => any;
|
27
|
+
postWithOutStringify: (url: string, data: any, header?: any) => any;
|
28
|
+
getSecurityValidation: () => any;
|
29
|
+
refreshSecurityValidation: () => Promise<void>;
|
30
|
+
}
|
package/lib/jitzSPHttpClient.js
CHANGED
@@ -1,191 +1,191 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
6
|
-
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8
|
-
});
|
9
|
-
};
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
14
|
-
function step(op) {
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
16
|
-
while (_) try {
|
17
|
-
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;
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
19
|
-
switch (op[0]) {
|
20
|
-
case 0: case 1: t = op; break;
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
24
|
-
default:
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
29
|
-
if (t[2]) _.ops.pop();
|
30
|
-
_.trys.pop(); continue;
|
31
|
-
}
|
32
|
-
op = body.call(thisArg, _);
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
35
|
-
}
|
36
|
-
};
|
37
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
38
|
-
var axios_1 = require("axios");
|
39
|
-
var JitzSPContext = /** @class */ (function () {
|
40
|
-
function JitzSPContext(siteUrl) {
|
41
|
-
var _this = this;
|
42
|
-
this.init = function () { return __awaiter(_this, void 0, void 0, function () {
|
43
|
-
return __generator(this, function (_a) {
|
44
|
-
switch (_a.label) {
|
45
|
-
case 0: return [4 /*yield*/, this.client.init()];
|
46
|
-
case 1:
|
47
|
-
_a.sent();
|
48
|
-
return [2 /*return*/];
|
49
|
-
}
|
50
|
-
});
|
51
|
-
}); };
|
52
|
-
this.siteUrl = siteUrl;
|
53
|
-
this.client = new JitzSPHttpClient(siteUrl);
|
54
|
-
}
|
55
|
-
return JitzSPContext;
|
56
|
-
}());
|
57
|
-
exports.JitzSPContext = JitzSPContext;
|
58
|
-
var JitzSPHttpClient = /** @class */ (function () {
|
59
|
-
function JitzSPHttpClient(siteUrl) {
|
60
|
-
var _this = this;
|
61
|
-
if (siteUrl === void 0) { siteUrl = ""; }
|
62
|
-
this.securityToken = "";
|
63
|
-
this.header = {
|
64
|
-
Accept: "application/json;odata=verbose",
|
65
|
-
"Content-Type": "application/json;odata=verbose",
|
66
|
-
};
|
67
|
-
this.init = function () { return __awaiter(_this, void 0, void 0, function () {
|
68
|
-
return __generator(this, function (_a) {
|
69
|
-
switch (_a.label) {
|
70
|
-
case 0: return [4 /*yield*/, this.refreshSecurityValidation()];
|
71
|
-
case 1:
|
72
|
-
_a.sent();
|
73
|
-
return [2 /*return*/];
|
74
|
-
}
|
75
|
-
});
|
76
|
-
}); };
|
77
|
-
this.get = function (url, header) {
|
78
|
-
header = header || _this.header;
|
79
|
-
header["X-RequestDigest"] = _this.securityToken;
|
80
|
-
var authOptions = {
|
81
|
-
method: "GET",
|
82
|
-
url: url,
|
83
|
-
data: JSON.stringify({}),
|
84
|
-
headers: header,
|
85
|
-
json: true,
|
86
|
-
};
|
87
|
-
return _this.client(authOptions);
|
88
|
-
// return this.getSecurityValidation().then((ctx: any) => {
|
89
|
-
// this.securityToken = ctx.data.d.GetContextWebInformation.FormDigestValue;
|
90
|
-
// header["X-RequestDigest"] = this.securityToken;
|
91
|
-
// var authOptions = {
|
92
|
-
// method: "GET",
|
93
|
-
// url: url,
|
94
|
-
// data: JSON.stringify({}),
|
95
|
-
// headers: header,
|
96
|
-
// json: true,
|
97
|
-
// };
|
98
|
-
// return this.client(authOptions);
|
99
|
-
// });
|
100
|
-
};
|
101
|
-
this.post = function (url, data, header) {
|
102
|
-
// debugger;
|
103
|
-
header = header || _this.header;
|
104
|
-
header["X-RequestDigest"] = _this.securityToken;
|
105
|
-
var authOptions = {
|
106
|
-
method: "POST",
|
107
|
-
url: url,
|
108
|
-
data: JSON.stringify(data),
|
109
|
-
headers: header,
|
110
|
-
json: true,
|
111
|
-
};
|
112
|
-
return _this.client(authOptions);
|
113
|
-
// return this.getSecurityValidation().then((ctx: any) => {
|
114
|
-
// this.securityToken = ctx.data.d.GetContextWebInformation.FormDigestValue;
|
115
|
-
// header["X-RequestDigest"] = this.securityToken;
|
116
|
-
// var authOptions = {
|
117
|
-
// method: "POST",
|
118
|
-
// url: url,
|
119
|
-
// data: JSON.stringify(data),
|
120
|
-
// headers: header,
|
121
|
-
// json: true,
|
122
|
-
// };
|
123
|
-
// return this.client(authOptions);
|
124
|
-
// });
|
125
|
-
};
|
126
|
-
this.postWithOutStringify = function (url, data, header) {
|
127
|
-
// debugger;
|
128
|
-
header = header || _this.header;
|
129
|
-
header["X-RequestDigest"] = _this.securityToken;
|
130
|
-
var authOptions = {
|
131
|
-
method: "POST",
|
132
|
-
url: url,
|
133
|
-
data: data,
|
134
|
-
headers: header,
|
135
|
-
json: true,
|
136
|
-
};
|
137
|
-
return _this.client(authOptions);
|
138
|
-
};
|
139
|
-
this.getSecurityValidation = function () {
|
140
|
-
var 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 _this.client(authOptions);
|
151
|
-
};
|
152
|
-
this.refreshSecurityValidation = function () { return __awaiter(_this, void 0, void 0, function () {
|
153
|
-
var authOptions;
|
154
|
-
var _this = this;
|
155
|
-
return __generator(this, function (_a) {
|
156
|
-
switch (_a.label) {
|
157
|
-
case 0:
|
158
|
-
authOptions = {
|
159
|
-
method: "POST",
|
160
|
-
url: "/_api/contextinfo",
|
161
|
-
data: JSON.stringify({}),
|
162
|
-
headers: {
|
163
|
-
Accept: "application/json;odata=verbose",
|
164
|
-
"Content-Type": "application/json;odata=verbose",
|
165
|
-
},
|
166
|
-
json: true,
|
167
|
-
};
|
168
|
-
return [4 /*yield*/, this.client(authOptions).then(function (context) {
|
169
|
-
_this.securityToken =
|
170
|
-
context.data.d.GetContextWebInformation.FormDigestValue;
|
171
|
-
// console.log("Token:- "+this.securityToken);
|
172
|
-
var interval = setInterval(function () {
|
173
|
-
_this.refreshSecurityValidation();
|
174
|
-
clearInterval(interval);
|
175
|
-
}, 600000); //300000
|
176
|
-
})];
|
177
|
-
case 1:
|
178
|
-
_a.sent();
|
179
|
-
return [2 /*return*/];
|
180
|
-
}
|
181
|
-
});
|
182
|
-
}); };
|
183
|
-
this.siteUrl = siteUrl;
|
184
|
-
this.securityToken = "";
|
185
|
-
this.client = axios_1.default.create({
|
186
|
-
baseURL: this.siteUrl,
|
187
|
-
});
|
188
|
-
}
|
189
|
-
return JitzSPHttpClient;
|
190
|
-
}());
|
191
|
-
exports.default = JitzSPHttpClient;
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
6
|
+
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8
|
+
});
|
9
|
+
};
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
14
|
+
function step(op) {
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
16
|
+
while (_) try {
|
17
|
+
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;
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
19
|
+
switch (op[0]) {
|
20
|
+
case 0: case 1: t = op; break;
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
24
|
+
default:
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
29
|
+
if (t[2]) _.ops.pop();
|
30
|
+
_.trys.pop(); continue;
|
31
|
+
}
|
32
|
+
op = body.call(thisArg, _);
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
35
|
+
}
|
36
|
+
};
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
38
|
+
var axios_1 = require("axios");
|
39
|
+
var JitzSPContext = /** @class */ (function () {
|
40
|
+
function JitzSPContext(siteUrl) {
|
41
|
+
var _this = this;
|
42
|
+
this.init = function () { return __awaiter(_this, void 0, void 0, function () {
|
43
|
+
return __generator(this, function (_a) {
|
44
|
+
switch (_a.label) {
|
45
|
+
case 0: return [4 /*yield*/, this.client.init()];
|
46
|
+
case 1:
|
47
|
+
_a.sent();
|
48
|
+
return [2 /*return*/];
|
49
|
+
}
|
50
|
+
});
|
51
|
+
}); };
|
52
|
+
this.siteUrl = siteUrl;
|
53
|
+
this.client = new JitzSPHttpClient(siteUrl);
|
54
|
+
}
|
55
|
+
return JitzSPContext;
|
56
|
+
}());
|
57
|
+
exports.JitzSPContext = JitzSPContext;
|
58
|
+
var JitzSPHttpClient = /** @class */ (function () {
|
59
|
+
function JitzSPHttpClient(siteUrl) {
|
60
|
+
var _this = this;
|
61
|
+
if (siteUrl === void 0) { siteUrl = ""; }
|
62
|
+
this.securityToken = "";
|
63
|
+
this.header = {
|
64
|
+
Accept: "application/json;odata=verbose",
|
65
|
+
"Content-Type": "application/json;odata=verbose",
|
66
|
+
};
|
67
|
+
this.init = function () { return __awaiter(_this, void 0, void 0, function () {
|
68
|
+
return __generator(this, function (_a) {
|
69
|
+
switch (_a.label) {
|
70
|
+
case 0: return [4 /*yield*/, this.refreshSecurityValidation()];
|
71
|
+
case 1:
|
72
|
+
_a.sent();
|
73
|
+
return [2 /*return*/];
|
74
|
+
}
|
75
|
+
});
|
76
|
+
}); };
|
77
|
+
this.get = function (url, header) {
|
78
|
+
header = header || _this.header;
|
79
|
+
header["X-RequestDigest"] = _this.securityToken;
|
80
|
+
var authOptions = {
|
81
|
+
method: "GET",
|
82
|
+
url: url,
|
83
|
+
data: JSON.stringify({}),
|
84
|
+
headers: header,
|
85
|
+
json: true,
|
86
|
+
};
|
87
|
+
return _this.client(authOptions);
|
88
|
+
// return this.getSecurityValidation().then((ctx: any) => {
|
89
|
+
// this.securityToken = ctx.data.d.GetContextWebInformation.FormDigestValue;
|
90
|
+
// header["X-RequestDigest"] = this.securityToken;
|
91
|
+
// var authOptions = {
|
92
|
+
// method: "GET",
|
93
|
+
// url: url,
|
94
|
+
// data: JSON.stringify({}),
|
95
|
+
// headers: header,
|
96
|
+
// json: true,
|
97
|
+
// };
|
98
|
+
// return this.client(authOptions);
|
99
|
+
// });
|
100
|
+
};
|
101
|
+
this.post = function (url, data, header) {
|
102
|
+
// debugger;
|
103
|
+
header = header || _this.header;
|
104
|
+
header["X-RequestDigest"] = _this.securityToken;
|
105
|
+
var authOptions = {
|
106
|
+
method: "POST",
|
107
|
+
url: url,
|
108
|
+
data: JSON.stringify(data),
|
109
|
+
headers: header,
|
110
|
+
json: true,
|
111
|
+
};
|
112
|
+
return _this.client(authOptions);
|
113
|
+
// return this.getSecurityValidation().then((ctx: any) => {
|
114
|
+
// this.securityToken = ctx.data.d.GetContextWebInformation.FormDigestValue;
|
115
|
+
// header["X-RequestDigest"] = this.securityToken;
|
116
|
+
// var authOptions = {
|
117
|
+
// method: "POST",
|
118
|
+
// url: url,
|
119
|
+
// data: JSON.stringify(data),
|
120
|
+
// headers: header,
|
121
|
+
// json: true,
|
122
|
+
// };
|
123
|
+
// return this.client(authOptions);
|
124
|
+
// });
|
125
|
+
};
|
126
|
+
this.postWithOutStringify = function (url, data, header) {
|
127
|
+
// debugger;
|
128
|
+
header = header || _this.header;
|
129
|
+
header["X-RequestDigest"] = _this.securityToken;
|
130
|
+
var authOptions = {
|
131
|
+
method: "POST",
|
132
|
+
url: url,
|
133
|
+
data: data,
|
134
|
+
headers: header,
|
135
|
+
json: true,
|
136
|
+
};
|
137
|
+
return _this.client(authOptions);
|
138
|
+
};
|
139
|
+
this.getSecurityValidation = function () {
|
140
|
+
var 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 _this.client(authOptions);
|
151
|
+
};
|
152
|
+
this.refreshSecurityValidation = function () { return __awaiter(_this, void 0, void 0, function () {
|
153
|
+
var authOptions;
|
154
|
+
var _this = this;
|
155
|
+
return __generator(this, function (_a) {
|
156
|
+
switch (_a.label) {
|
157
|
+
case 0:
|
158
|
+
authOptions = {
|
159
|
+
method: "POST",
|
160
|
+
url: "/_api/contextinfo",
|
161
|
+
data: JSON.stringify({}),
|
162
|
+
headers: {
|
163
|
+
Accept: "application/json;odata=verbose",
|
164
|
+
"Content-Type": "application/json;odata=verbose",
|
165
|
+
},
|
166
|
+
json: true,
|
167
|
+
};
|
168
|
+
return [4 /*yield*/, this.client(authOptions).then(function (context) {
|
169
|
+
_this.securityToken =
|
170
|
+
context.data.d.GetContextWebInformation.FormDigestValue;
|
171
|
+
// console.log("Token:- "+this.securityToken);
|
172
|
+
var interval = setInterval(function () {
|
173
|
+
_this.refreshSecurityValidation();
|
174
|
+
clearInterval(interval);
|
175
|
+
}, 600000); //300000
|
176
|
+
})];
|
177
|
+
case 1:
|
178
|
+
_a.sent();
|
179
|
+
return [2 /*return*/];
|
180
|
+
}
|
181
|
+
});
|
182
|
+
}); };
|
183
|
+
this.siteUrl = siteUrl;
|
184
|
+
this.securityToken = "";
|
185
|
+
this.client = axios_1.default.create({
|
186
|
+
baseURL: this.siteUrl,
|
187
|
+
});
|
188
|
+
}
|
189
|
+
return JitzSPHttpClient;
|
190
|
+
}());
|
191
|
+
exports.default = JitzSPHttpClient;
|
@@ -1,16 +1,17 @@
|
|
1
|
-
import { IJitzSPContext } from "../jitzSPHttpClient";
|
2
|
-
import { ICommonRepository } from "./ICommonRepository";
|
3
|
-
import { IEmail } from "../common/IModels";
|
4
|
-
export default class CommonRepository implements ICommonRepository {
|
5
|
-
context: IJitzSPContext;
|
6
|
-
constructor(context: IJitzSPContext);
|
7
|
-
sendEmail(email: IEmail): Promise<boolean>;
|
8
|
-
getData(listName: string, selectFields?: string, expand?: string, filters?: string, orderBy?: string, top?: number, skipTokenUniqueField?: string, skipTokenUniqueFieldValue?: string): Promise<any>;
|
9
|
-
get(url: string): Promise<any>;
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
1
|
+
import { IJitzSPContext } from "../jitzSPHttpClient";
|
2
|
+
import { ICommonRepository } from "./ICommonRepository";
|
3
|
+
import { IEmail } from "../common/IModels";
|
4
|
+
export default class CommonRepository implements ICommonRepository {
|
5
|
+
context: IJitzSPContext;
|
6
|
+
constructor(context: IJitzSPContext);
|
7
|
+
sendEmail(email: IEmail): Promise<boolean>;
|
8
|
+
getData(listName: string, selectFields?: string, expand?: string, filters?: string, orderBy?: string, top?: number, skipTokenUniqueField?: string, skipTokenUniqueFieldValue?: string): Promise<any>;
|
9
|
+
get(url: string): Promise<any>;
|
10
|
+
post(url: string, data: any, header?: any): Promise<any>;
|
11
|
+
getFiles(libraryName: string, selectFields: string, filter: string, expandFields: string): Promise<any>;
|
12
|
+
uploadFile(libraryName: string, fileName: string, arrayBuffer: ArrayBuffer): Promise<any>;
|
13
|
+
getFileItem(libraryName: string, fileUrl: string): Promise<any>;
|
14
|
+
updateMetadata(listName: string, item: any): Promise<any>;
|
15
|
+
deleteFile(listName: string, id: number): Promise<boolean>;
|
16
|
+
private getEntityType;
|
17
|
+
}
|