jitz-sharepoint-utilities 2.0.11 → 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.
- package/data/context/Repository.ts +1 -1
- package/package.json +1 -1
- package/lib/common/IModels.d.ts +0 -40
- package/lib/common/IModels.js +0 -2
- package/lib/common/IObjects.d.ts +0 -72
- package/lib/common/IObjects.js +0 -30
- package/lib/controls/JitzGrid.d.ts +0 -75
- package/lib/controls/JitzGrid.js +0 -606
- package/lib/controls/JitzImage.d.ts +0 -14
- package/lib/controls/JitzImage.js +0 -37
- package/lib/controls/JitzPeoplePicker.d.ts +0 -49
- package/lib/controls/JitzPeoplePicker.js +0 -311
- package/lib/controls/JitzPersonInfo.d.ts +0 -32
- package/lib/controls/JitzPersonInfo.js +0 -98
- package/lib/controls/JitzPersona.d.ts +0 -23
- package/lib/controls/JitzPersona.js +0 -48
- package/lib/data/context/CommonRepository.d.ts +0 -17
- package/lib/data/context/CommonRepository.js +0 -287
- package/lib/data/context/JitzContext.d.ts +0 -13
- package/lib/data/context/JitzContext.js +0 -80
- package/lib/data/context/JitzSPContext.d.ts +0 -8
- package/lib/data/context/JitzSPContext.js +0 -58
- package/lib/data/context/JitzSPHttpClient.d.ts +0 -14
- package/lib/data/context/JitzSPHttpClient.js +0 -173
- package/lib/data/context/List.d.ts +0 -39
- package/lib/data/context/List.js +0 -492
- package/lib/data/context/Repository.d.ts +0 -22
- package/lib/data/context/Repository.js +0 -486
- package/lib/data/interfaces/ICommonRepository.d.ts +0 -6
- package/lib/data/interfaces/ICommonRepository.js +0 -2
- package/lib/data/interfaces/IJitzContext.d.ts +0 -10
- package/lib/data/interfaces/IJitzContext.js +0 -2
- package/lib/data/interfaces/IJitzSPContext.d.ts +0 -6
- package/lib/data/interfaces/IJitzSPContext.js +0 -2
- package/lib/data/interfaces/IJitzSPHttpClient.d.ts +0 -6
- package/lib/data/interfaces/IJitzSPHttpClient.js +0 -2
- package/lib/data/interfaces/IList.d.ts +0 -26
- package/lib/data/interfaces/IList.js +0 -2
- package/lib/data/interfaces/IModels.d.ts +0 -32
- package/lib/data/interfaces/IModels.js +0 -2
- package/lib/data/interfaces/IRepository.d.ts +0 -17
- package/lib/data/interfaces/IRepository.js +0 -2
- package/lib/jitzHttpClient.d.ts +0 -11
- package/lib/jitzHttpClient.js +0 -37
- package/lib/jitzSPHttpClient.d.ts +0 -30
- package/lib/jitzSPHttpClient.js +0 -193
- package/lib/repositories/CommonRepository.d.ts +0 -17
- package/lib/repositories/CommonRepository.js +0 -288
- package/lib/repositories/ICommonRepository.d.ts +0 -6
- package/lib/repositories/ICommonRepository.js +0 -2
- package/lib/repositories/IRepository.d.ts +0 -13
- package/lib/repositories/IRepository.js +0 -2
- package/lib/repositories/Repository.d.ts +0 -18
- package/lib/repositories/Repository.js +0 -394
- package/lib/services/GraphService.d.ts +0 -10
- package/lib/services/GraphService.js +0 -105
- package/lib/services/UserService.d.ts +0 -15
- package/lib/services/UserService.js +0 -202
- package/lib/services/UtilityService.d.ts +0 -29
- package/lib/services/UtilityService.js +0 -254
package/lib/jitzHttpClient.js
DELETED
@@ -1,37 +0,0 @@
|
|
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 +0,0 @@
|
|
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
DELETED
@@ -1,193 +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
|
-
exports.JitzSPContext = void 0;
|
40
|
-
var axios_1 = require("axios");
|
41
|
-
var JitzSPContext = /** @class */ (function () {
|
42
|
-
function JitzSPContext(siteUrl) {
|
43
|
-
var _this = this;
|
44
|
-
this.init = function () { return __awaiter(_this, void 0, void 0, function () {
|
45
|
-
return __generator(this, function (_a) {
|
46
|
-
switch (_a.label) {
|
47
|
-
case 0: return [4 /*yield*/, this.client.init()];
|
48
|
-
case 1:
|
49
|
-
_a.sent();
|
50
|
-
return [2 /*return*/];
|
51
|
-
}
|
52
|
-
});
|
53
|
-
}); };
|
54
|
-
this.siteUrl = siteUrl;
|
55
|
-
this.client = new JitzSPHttpClient(siteUrl);
|
56
|
-
}
|
57
|
-
return JitzSPContext;
|
58
|
-
}());
|
59
|
-
exports.JitzSPContext = JitzSPContext;
|
60
|
-
var JitzSPHttpClient = /** @class */ (function () {
|
61
|
-
function JitzSPHttpClient(siteUrl) {
|
62
|
-
if (siteUrl === void 0) { siteUrl = ""; }
|
63
|
-
var _this = this;
|
64
|
-
this.securityToken = "";
|
65
|
-
this.header = {
|
66
|
-
Accept: "application/json;odata=verbose",
|
67
|
-
"Content-Type": "application/json;odata=verbose",
|
68
|
-
};
|
69
|
-
this.init = function () { return __awaiter(_this, void 0, void 0, function () {
|
70
|
-
return __generator(this, function (_a) {
|
71
|
-
switch (_a.label) {
|
72
|
-
case 0: return [4 /*yield*/, this.refreshSecurityValidation()];
|
73
|
-
case 1:
|
74
|
-
_a.sent();
|
75
|
-
return [2 /*return*/];
|
76
|
-
}
|
77
|
-
});
|
78
|
-
}); };
|
79
|
-
this.get = function (url, header) {
|
80
|
-
header = header || _this.header;
|
81
|
-
header["X-RequestDigest"] = _this.securityToken;
|
82
|
-
var authOptions = {
|
83
|
-
method: "GET",
|
84
|
-
url: url,
|
85
|
-
data: JSON.stringify({}),
|
86
|
-
headers: header,
|
87
|
-
json: true,
|
88
|
-
};
|
89
|
-
return _this.client(authOptions);
|
90
|
-
// return this.getSecurityValidation().then((ctx: any) => {
|
91
|
-
// this.securityToken = ctx.data.d.GetContextWebInformation.FormDigestValue;
|
92
|
-
// header["X-RequestDigest"] = this.securityToken;
|
93
|
-
// var authOptions = {
|
94
|
-
// method: "GET",
|
95
|
-
// url: url,
|
96
|
-
// data: JSON.stringify({}),
|
97
|
-
// headers: header,
|
98
|
-
// json: true,
|
99
|
-
// };
|
100
|
-
// return this.client(authOptions);
|
101
|
-
// });
|
102
|
-
};
|
103
|
-
this.post = function (url, data, header) {
|
104
|
-
// debugger;
|
105
|
-
header = header || _this.header;
|
106
|
-
header["X-RequestDigest"] = _this.securityToken;
|
107
|
-
var authOptions = {
|
108
|
-
method: "POST",
|
109
|
-
url: url,
|
110
|
-
data: JSON.stringify(data),
|
111
|
-
headers: header,
|
112
|
-
json: true,
|
113
|
-
};
|
114
|
-
return _this.client(authOptions);
|
115
|
-
// return this.getSecurityValidation().then((ctx: any) => {
|
116
|
-
// this.securityToken = ctx.data.d.GetContextWebInformation.FormDigestValue;
|
117
|
-
// header["X-RequestDigest"] = this.securityToken;
|
118
|
-
// var authOptions = {
|
119
|
-
// method: "POST",
|
120
|
-
// url: url,
|
121
|
-
// data: JSON.stringify(data),
|
122
|
-
// headers: header,
|
123
|
-
// json: true,
|
124
|
-
// };
|
125
|
-
// return this.client(authOptions);
|
126
|
-
// });
|
127
|
-
};
|
128
|
-
this.postWithOutStringify = function (url, data, header) {
|
129
|
-
// debugger;
|
130
|
-
header = header || _this.header;
|
131
|
-
header["X-RequestDigest"] = _this.securityToken;
|
132
|
-
var authOptions = {
|
133
|
-
method: "POST",
|
134
|
-
url: url,
|
135
|
-
data: data,
|
136
|
-
headers: header,
|
137
|
-
json: true,
|
138
|
-
};
|
139
|
-
return _this.client(authOptions);
|
140
|
-
};
|
141
|
-
this.getSecurityValidation = function () {
|
142
|
-
var authOptions = {
|
143
|
-
method: "POST",
|
144
|
-
url: "/_api/contextinfo",
|
145
|
-
data: JSON.stringify({}),
|
146
|
-
headers: {
|
147
|
-
Accept: "application/json;odata=verbose",
|
148
|
-
"Content-Type": "application/json;odata=verbose",
|
149
|
-
},
|
150
|
-
json: true,
|
151
|
-
};
|
152
|
-
return _this.client(authOptions);
|
153
|
-
};
|
154
|
-
this.refreshSecurityValidation = function () { return __awaiter(_this, void 0, void 0, function () {
|
155
|
-
var authOptions;
|
156
|
-
var _this = this;
|
157
|
-
return __generator(this, function (_a) {
|
158
|
-
switch (_a.label) {
|
159
|
-
case 0:
|
160
|
-
authOptions = {
|
161
|
-
method: "POST",
|
162
|
-
url: "/_api/contextinfo",
|
163
|
-
data: JSON.stringify({}),
|
164
|
-
headers: {
|
165
|
-
Accept: "application/json;odata=verbose",
|
166
|
-
"Content-Type": "application/json;odata=verbose",
|
167
|
-
},
|
168
|
-
json: true,
|
169
|
-
};
|
170
|
-
return [4 /*yield*/, this.client(authOptions).then(function (context) {
|
171
|
-
_this.securityToken =
|
172
|
-
context.data.d.GetContextWebInformation.FormDigestValue;
|
173
|
-
// console.log("Token:- "+this.securityToken);
|
174
|
-
var interval = setInterval(function () {
|
175
|
-
_this.refreshSecurityValidation();
|
176
|
-
clearInterval(interval);
|
177
|
-
}, 600000); //300000
|
178
|
-
})];
|
179
|
-
case 1:
|
180
|
-
_a.sent();
|
181
|
-
return [2 /*return*/];
|
182
|
-
}
|
183
|
-
});
|
184
|
-
}); };
|
185
|
-
this.siteUrl = siteUrl;
|
186
|
-
this.securityToken = "";
|
187
|
-
this.client = axios_1.default.create({
|
188
|
-
baseURL: this.siteUrl,
|
189
|
-
});
|
190
|
-
}
|
191
|
-
return JitzSPHttpClient;
|
192
|
-
}());
|
193
|
-
exports.default = JitzSPHttpClient;
|
@@ -1,17 +0,0 @@
|
|
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
|
-
}
|
@@ -1,288 +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 (filters != null && filters != "") {
|
77
|
-
queryUrlGetAllItems = queryUrlGetAllItems + "&$filter=" + filters;
|
78
|
-
}
|
79
|
-
if (orderBy != null && orderBy != "") {
|
80
|
-
queryUrlGetAllItems = queryUrlGetAllItems + "&$orderby=" + orderBy;
|
81
|
-
}
|
82
|
-
if (top != null && top != undefined && top > 0) {
|
83
|
-
queryUrlGetAllItems = queryUrlGetAllItems + "&$top=" + top;
|
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
|
-
var item;
|
209
|
-
return __generator(this, function (_a) {
|
210
|
-
switch (_a.label) {
|
211
|
-
case 0: return [4 /*yield*/, this.getEntityType(listName).then(function (entityType) {
|
212
|
-
item.__metadata = {
|
213
|
-
//etag: "1",
|
214
|
-
type: entityType,
|
215
|
-
};
|
216
|
-
var requestUrl = "_api/web/lists/getbytitle('".concat(listName, "')/items(").concat(item.Id, ")");
|
217
|
-
return _this.context.client
|
218
|
-
.post(requestUrl, item, {
|
219
|
-
Accept: "application/json;odata=nometadata",
|
220
|
-
"Content-type": "application/json;odata=verbose",
|
221
|
-
"odata-version": "",
|
222
|
-
"IF-MATCH": "*",
|
223
|
-
"X-HTTP-Method": "MERGE",
|
224
|
-
})
|
225
|
-
.then(function (response) {
|
226
|
-
if (response.status >= 200 && response.status < 300) {
|
227
|
-
return item;
|
228
|
-
}
|
229
|
-
else {
|
230
|
-
console.log(JSON.stringify(response));
|
231
|
-
return Promise.reject(new Error(JSON.stringify(response)));
|
232
|
-
}
|
233
|
-
});
|
234
|
-
})];
|
235
|
-
case 1:
|
236
|
-
item = _a.sent();
|
237
|
-
url = "/_api/web/lists/getbytitle('".concat(listName, "')/items(").concat(item.Id, ")?$select=*,File/Name,File/ServerRelativeUrl&$expand=File");
|
238
|
-
return [2 /*return*/, this.context.client.get(url).then(function (response) {
|
239
|
-
if (response.status >= 200 && response.status <= 300) {
|
240
|
-
var json = response.data.d;
|
241
|
-
return json;
|
242
|
-
}
|
243
|
-
else {
|
244
|
-
return Promise.reject(new Error(JSON.stringify(response)));
|
245
|
-
}
|
246
|
-
})];
|
247
|
-
}
|
248
|
-
});
|
249
|
-
});
|
250
|
-
};
|
251
|
-
CommonRepository.prototype.deleteFile = function (listName, id) {
|
252
|
-
var requestUrl = "_api/web/lists/getbytitle('".concat(listName, "')/items(").concat(id, ")");
|
253
|
-
return this.context.client
|
254
|
-
.post(requestUrl, {}, {
|
255
|
-
Accept: "application/json;odata=nometadata",
|
256
|
-
"Content-type": "application/json;odata=verbose",
|
257
|
-
"odata-version": "",
|
258
|
-
"IF-MATCH": "*",
|
259
|
-
"X-HTTP-Method": "DELETE",
|
260
|
-
})
|
261
|
-
.then(function (response) {
|
262
|
-
if (response.status >= 200 && response.status < 300) {
|
263
|
-
return true;
|
264
|
-
}
|
265
|
-
else {
|
266
|
-
return Promise.reject(new Error(JSON.stringify(response)));
|
267
|
-
}
|
268
|
-
});
|
269
|
-
};
|
270
|
-
CommonRepository.prototype.getEntityType = function (listName) {
|
271
|
-
var _this = this;
|
272
|
-
return new Promise(function (resolve, reject) {
|
273
|
-
_this.context.client
|
274
|
-
.get("_api/web/lists/getbytitle('".concat(listName, "')?$select=ListItemEntityTypeFullName"))
|
275
|
-
.then(function (response) {
|
276
|
-
return response;
|
277
|
-
}, function (error) {
|
278
|
-
reject(error);
|
279
|
-
})
|
280
|
-
.then(function (response) {
|
281
|
-
var _listEntityType = response.data.d.ListItemEntityTypeFullName;
|
282
|
-
resolve(_listEntityType || "");
|
283
|
-
});
|
284
|
-
});
|
285
|
-
};
|
286
|
-
return CommonRepository;
|
287
|
-
}());
|
288
|
-
exports.default = CommonRepository;
|
@@ -1,13 +0,0 @@
|
|
1
|
-
import { IJitzSPContext } from "../jitzSPHttpClient";
|
2
|
-
import { IModel } from "../common/IModels";
|
3
|
-
export interface IRepository<T extends IModel> {
|
4
|
-
context: IJitzSPContext;
|
5
|
-
listName: string;
|
6
|
-
getAll(selectFields?: string, expand?: string, filters?: string, orderBy?: string, top?: number, skipTokenUniqueField?: string, skipTokenUniqueFieldValue?: string): Promise<T[]>;
|
7
|
-
itemsCount(): Promise<number>;
|
8
|
-
getItemById(id: number, selectFields?: string, expand?: string): Promise<T>;
|
9
|
-
createItem(item: T): Promise<T>;
|
10
|
-
updateItem(item: T): Promise<T>;
|
11
|
-
deleteItem(id: number): Promise<boolean>;
|
12
|
-
getAllRecursive(selectFields?: string, expand?: string, filters?: string, orderBy?: string, top?: number, maxRecursiveCount?: number): any;
|
13
|
-
}
|
@@ -1,18 +0,0 @@
|
|
1
|
-
import { IRepository } from "./IRepository";
|
2
|
-
import { IModel } from "../common/IModels";
|
3
|
-
import { IJitzSPContext } from "../jitzSPHttpClient";
|
4
|
-
export default class Repository<T extends IModel> implements IRepository<T> {
|
5
|
-
private _listEntityType?;
|
6
|
-
context: IJitzSPContext;
|
7
|
-
listName: string;
|
8
|
-
constructor(context: IJitzSPContext, listName: string);
|
9
|
-
getAll(selectFields?: string, expand?: string, filters?: string, orderBy?: string, top?: number, skipTokenUniqueField?: string, skipTokenUniqueFieldValue?: string): Promise<T[]>;
|
10
|
-
getAllRecursive(selectFields?: string, expand?: string, filters?: string, orderBy?: string, top?: number, maxRecursiveCount?: number): Promise<T[]>;
|
11
|
-
private recursiveFetch;
|
12
|
-
itemsCount(filters?: string): any;
|
13
|
-
getItemById(id: number, selectFields?: string, expand?: string): Promise<T>;
|
14
|
-
createItem(item: T): Promise<T>;
|
15
|
-
updateItem(item: T): Promise<T>;
|
16
|
-
deleteItem(id: number): Promise<boolean>;
|
17
|
-
private getEntityType;
|
18
|
-
}
|