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
@@ -1,39 +0,0 @@
|
|
1
|
-
import IJitzContext from "../interfaces/IJitzContext";
|
2
|
-
import { IList } from "../interfaces/IList";
|
3
|
-
import { IModel } from "../interfaces/IModels";
|
4
|
-
import { IRepository } from "../interfaces/IRepository";
|
5
|
-
export default class List<T extends IModel> implements IList<T> {
|
6
|
-
context: IJitzContext;
|
7
|
-
listName: string;
|
8
|
-
listGuid: string;
|
9
|
-
_nextPageLink: string;
|
10
|
-
top: number;
|
11
|
-
indexLimit: number;
|
12
|
-
simpleFields: string[];
|
13
|
-
userTypeFields: string[];
|
14
|
-
lookUpFields: string[];
|
15
|
-
additionalExpandFields: string[];
|
16
|
-
repository: IRepository<T>;
|
17
|
-
filters?: string;
|
18
|
-
upperId: number;
|
19
|
-
lowerId: number;
|
20
|
-
orderBy?: string | undefined;
|
21
|
-
constructor(jitzContext: IJitzContext, listName: string, simpleFields: string[], userTypeFields: string[], lookUpFields: string[], additionalExpandFields: string[], listGuid?: string);
|
22
|
-
getItems: (filters?: string, orderby?: string, top?: number, skip?: number) => Promise<T[]>;
|
23
|
-
loadMore: () => Promise<T[]>;
|
24
|
-
getItemsIndexed: (filterQuery?: string, orderby?: string, top?: number) => Promise<T[]>;
|
25
|
-
loadMoreIndexed(): Promise<T[]>;
|
26
|
-
getItemsIndexedRecursive: (filter: string) => Promise<T[]>;
|
27
|
-
continueFetch: () => Promise<any[]>;
|
28
|
-
getData: (filter: string) => Promise<T[]>;
|
29
|
-
private getLowerId;
|
30
|
-
getItemById: (id: number) => Promise<T>;
|
31
|
-
getItemsRecursive: (filters?: string, orderby?: string, top?: number, maxRecursiveCount?: number) => Promise<T[]>;
|
32
|
-
getItemsCount: (filters?: string) => Promise<number>;
|
33
|
-
create: (item: T) => Promise<T>;
|
34
|
-
update: (item: T) => Promise<T>;
|
35
|
-
delete: (id: number) => Promise<boolean>;
|
36
|
-
private setPropertiesForSharePointApi;
|
37
|
-
private getSelectFieldsForSharePointApi;
|
38
|
-
private getSelectFieldsForGraphApi;
|
39
|
-
}
|
package/lib/data/context/List.js
DELETED
@@ -1,492 +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
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
39
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
40
|
-
if (ar || !(i in from)) {
|
41
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
42
|
-
ar[i] = from[i];
|
43
|
-
}
|
44
|
-
}
|
45
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
46
|
-
};
|
47
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
48
|
-
var Repository_1 = require("./Repository");
|
49
|
-
var List = /** @class */ (function () {
|
50
|
-
function List(jitzContext, listName, simpleFields, userTypeFields, lookUpFields, additionalExpandFields, listGuid) {
|
51
|
-
if (listGuid === void 0) { listGuid = ""; }
|
52
|
-
var _this = this;
|
53
|
-
// items: any[];
|
54
|
-
this.top = 100;
|
55
|
-
this.indexLimit = 5000;
|
56
|
-
this.simpleFields = [];
|
57
|
-
this.userTypeFields = [];
|
58
|
-
this.lookUpFields = [];
|
59
|
-
this.additionalExpandFields = [];
|
60
|
-
this.filters = "";
|
61
|
-
this.upperId = 0;
|
62
|
-
this.lowerId = 0;
|
63
|
-
this.getItems = function (filters, orderby, top, skip) { return __awaiter(_this, void 0, void 0, function () {
|
64
|
-
var items, expandFields, selectFields, response;
|
65
|
-
return __generator(this, function (_a) {
|
66
|
-
switch (_a.label) {
|
67
|
-
case 0:
|
68
|
-
this.top = top || this.top;
|
69
|
-
items = [];
|
70
|
-
expandFields = (__spreadArray(__spreadArray([], this.lookUpFields, true), this.userTypeFields, true) || []).join(",");
|
71
|
-
selectFields = this.getSelectFieldsForSharePointApi();
|
72
|
-
this.filters = filters;
|
73
|
-
this.orderBy = orderby;
|
74
|
-
return [4 /*yield*/, this.repository.getAll(selectFields, expandFields, filters, orderby, top || this.top, skip)];
|
75
|
-
case 1:
|
76
|
-
response = _a.sent();
|
77
|
-
this._nextPageLink = response.__next || "";
|
78
|
-
// console.log(items);
|
79
|
-
// this.items = items;
|
80
|
-
return [2 /*return*/, response.results];
|
81
|
-
}
|
82
|
-
});
|
83
|
-
}); };
|
84
|
-
this.loadMore = function () { return __awaiter(_this, void 0, void 0, function () {
|
85
|
-
var items, expandFields, selectFields, response, _a;
|
86
|
-
return __generator(this, function (_b) {
|
87
|
-
switch (_b.label) {
|
88
|
-
case 0:
|
89
|
-
_b.trys.push([0, 3, , 4]);
|
90
|
-
if (!(this._nextPageLink != undefined && this._nextPageLink.length > 0)) return [3 /*break*/, 2];
|
91
|
-
items = [];
|
92
|
-
expandFields = (__spreadArray(__spreadArray([], this.lookUpFields, true), this.userTypeFields, true) || []).join(",");
|
93
|
-
selectFields = this.getSelectFieldsForSharePointApi();
|
94
|
-
return [4 /*yield*/, this.repository.getAllFromUrl(this._nextPageLink)];
|
95
|
-
case 1:
|
96
|
-
response = _b.sent();
|
97
|
-
this._nextPageLink = response.__next || "";
|
98
|
-
// console.log(items);
|
99
|
-
// this.items = items;
|
100
|
-
return [2 /*return*/, response.results];
|
101
|
-
case 2: return [3 /*break*/, 4];
|
102
|
-
case 3:
|
103
|
-
_a = _b.sent();
|
104
|
-
return [3 /*break*/, 4];
|
105
|
-
case 4: return [2 /*return*/, []];
|
106
|
-
}
|
107
|
-
});
|
108
|
-
}); };
|
109
|
-
this.getItemsIndexed = function (filterQuery, orderby, top) { return __awaiter(_this, void 0, void 0, function () {
|
110
|
-
var filter, results;
|
111
|
-
var _this = this;
|
112
|
-
return __generator(this, function (_a) {
|
113
|
-
switch (_a.label) {
|
114
|
-
case 0:
|
115
|
-
this.top = top || this.top;
|
116
|
-
filter = "(Id ge 1)";
|
117
|
-
this.orderBy = orderby;
|
118
|
-
this.filters = filterQuery;
|
119
|
-
//Find latest Id
|
120
|
-
return [4 /*yield*/, this.repository
|
121
|
-
.getAll("*", "", "", "Id desc", 1)
|
122
|
-
.then(function (datacount) {
|
123
|
-
var _a;
|
124
|
-
if (((_a = datacount === null || datacount === void 0 ? void 0 : datacount.results) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
125
|
-
_this.upperId = datacount.results[0].Id;
|
126
|
-
}
|
127
|
-
})];
|
128
|
-
case 1:
|
129
|
-
//Find latest Id
|
130
|
-
_a.sent();
|
131
|
-
this.lowerId = this.getLowerId(this.upperId);
|
132
|
-
if (this.upperId > 1)
|
133
|
-
filter = "(Id gt ".concat(this.lowerId, " and Id le ").concat(this.upperId, ")");
|
134
|
-
filterQuery = "".concat(filter, " ").concat(filterQuery != undefined && filterQuery.length > 0
|
135
|
-
? "and ".concat(filterQuery)
|
136
|
-
: "");
|
137
|
-
return [4 /*yield*/, this.getData(filterQuery)];
|
138
|
-
case 2:
|
139
|
-
results = _a.sent();
|
140
|
-
return [2 /*return*/, results];
|
141
|
-
}
|
142
|
-
});
|
143
|
-
}); };
|
144
|
-
this.getItemsIndexedRecursive = function (filter) { return __awaiter(_this, void 0, void 0, function () {
|
145
|
-
var results, moreData;
|
146
|
-
return __generator(this, function (_a) {
|
147
|
-
switch (_a.label) {
|
148
|
-
case 0: return [4 /*yield*/, this.getItemsIndexed(filter)];
|
149
|
-
case 1:
|
150
|
-
results = _a.sent();
|
151
|
-
return [4 /*yield*/, this.continueFetch()];
|
152
|
-
case 2:
|
153
|
-
moreData = _a.sent();
|
154
|
-
results = __spreadArray(__spreadArray([], results, true), moreData, true);
|
155
|
-
return [2 /*return*/, results];
|
156
|
-
}
|
157
|
-
});
|
158
|
-
}); };
|
159
|
-
this.continueFetch = function () { return __awaiter(_this, void 0, void 0, function () {
|
160
|
-
var data, moreData, _a;
|
161
|
-
return __generator(this, function (_b) {
|
162
|
-
switch (_b.label) {
|
163
|
-
case 0:
|
164
|
-
data = [];
|
165
|
-
_b.label = 1;
|
166
|
-
case 1:
|
167
|
-
_b.trys.push([1, 5, , 6]);
|
168
|
-
return [4 /*yield*/, this.loadMoreIndexed()];
|
169
|
-
case 2:
|
170
|
-
data = _b.sent();
|
171
|
-
if (!(this.lowerId > 0)) return [3 /*break*/, 4];
|
172
|
-
return [4 /*yield*/, this.continueFetch()];
|
173
|
-
case 3:
|
174
|
-
moreData = _b.sent();
|
175
|
-
data = __spreadArray(__spreadArray([], data, true), moreData, true);
|
176
|
-
_b.label = 4;
|
177
|
-
case 4: return [3 /*break*/, 6];
|
178
|
-
case 5:
|
179
|
-
_a = _b.sent();
|
180
|
-
return [3 /*break*/, 6];
|
181
|
-
case 6: return [2 /*return*/, data];
|
182
|
-
}
|
183
|
-
});
|
184
|
-
}); };
|
185
|
-
this.getData = function (filter) { return __awaiter(_this, void 0, void 0, function () {
|
186
|
-
var expandFields, selectFields, response;
|
187
|
-
return __generator(this, function (_a) {
|
188
|
-
switch (_a.label) {
|
189
|
-
case 0:
|
190
|
-
expandFields = (__spreadArray(__spreadArray([], this.lookUpFields, true), this.userTypeFields, true) || []).join(",");
|
191
|
-
selectFields = this.getSelectFieldsForSharePointApi();
|
192
|
-
return [4 /*yield*/, this.repository.getAll(selectFields, expandFields, filter, this.orderBy || "Id desc", this.top)];
|
193
|
-
case 1:
|
194
|
-
response = _a.sent();
|
195
|
-
this._nextPageLink = response.__next || "";
|
196
|
-
return [2 /*return*/, response.results];
|
197
|
-
}
|
198
|
-
});
|
199
|
-
}); };
|
200
|
-
this.getLowerId = function (upperId) {
|
201
|
-
if (upperId > _this.indexLimit)
|
202
|
-
return upperId - _this.indexLimit;
|
203
|
-
else
|
204
|
-
return 0;
|
205
|
-
};
|
206
|
-
this.getItemById = function (id) { return __awaiter(_this, void 0, void 0, function () {
|
207
|
-
var item, expandFields, selectFields;
|
208
|
-
return __generator(this, function (_a) {
|
209
|
-
switch (_a.label) {
|
210
|
-
case 0:
|
211
|
-
expandFields = (__spreadArray(__spreadArray([], this.lookUpFields, true), this.userTypeFields, true) || []).join(",");
|
212
|
-
selectFields = this.getSelectFieldsForSharePointApi();
|
213
|
-
return [4 /*yield*/, this.repository.getItemById(id, selectFields, expandFields)];
|
214
|
-
case 1:
|
215
|
-
item = _a.sent();
|
216
|
-
return [2 /*return*/, item];
|
217
|
-
}
|
218
|
-
});
|
219
|
-
}); };
|
220
|
-
this.getItemsRecursive = function (filters_1, orderby_1) {
|
221
|
-
var args_1 = [];
|
222
|
-
for (var _i = 2; _i < arguments.length; _i++) {
|
223
|
-
args_1[_i - 2] = arguments[_i];
|
224
|
-
}
|
225
|
-
return __awaiter(_this, __spreadArray([filters_1, orderby_1], args_1, true), void 0, function (filters, orderby, top, maxRecursiveCount) {
|
226
|
-
var items, expandFields, selectFields;
|
227
|
-
if (top === void 0) { top = 5000; }
|
228
|
-
if (maxRecursiveCount === void 0) { maxRecursiveCount = 5; }
|
229
|
-
return __generator(this, function (_a) {
|
230
|
-
switch (_a.label) {
|
231
|
-
case 0:
|
232
|
-
items = [];
|
233
|
-
expandFields = (__spreadArray(__spreadArray([], this.lookUpFields, true), this.userTypeFields, true) || []).join(",");
|
234
|
-
selectFields = this.getSelectFieldsForSharePointApi();
|
235
|
-
return [4 /*yield*/, this.repository.getAllRecursive(selectFields, expandFields, filters, orderby, top || this.top, maxRecursiveCount)];
|
236
|
-
case 1:
|
237
|
-
items = _a.sent();
|
238
|
-
// console.log(items);
|
239
|
-
// this.items = items;
|
240
|
-
return [2 /*return*/, items];
|
241
|
-
}
|
242
|
-
});
|
243
|
-
});
|
244
|
-
};
|
245
|
-
this.getItemsCount = function (filters) { return __awaiter(_this, void 0, void 0, function () {
|
246
|
-
var count;
|
247
|
-
return __generator(this, function (_a) {
|
248
|
-
switch (_a.label) {
|
249
|
-
case 0: return [4 /*yield*/, this.repository.itemsCount(filters)];
|
250
|
-
case 1:
|
251
|
-
count = _a.sent();
|
252
|
-
return [2 /*return*/, count];
|
253
|
-
}
|
254
|
-
});
|
255
|
-
}); };
|
256
|
-
this.create = function (item) { return __awaiter(_this, void 0, void 0, function () {
|
257
|
-
var newItem;
|
258
|
-
return __generator(this, function (_a) {
|
259
|
-
switch (_a.label) {
|
260
|
-
case 0:
|
261
|
-
newItem = this.setPropertiesForSharePointApi(item);
|
262
|
-
return [4 /*yield*/, this.repository.createItem(newItem)];
|
263
|
-
case 1:
|
264
|
-
item = _a.sent();
|
265
|
-
// await this.context.graphClient
|
266
|
-
// .api(`/sites/${this.context.siteId}/lists/${this.listName}/items`)
|
267
|
-
// .post({ fields: item })
|
268
|
-
// .then((response: any) => {
|
269
|
-
// item = response;
|
270
|
-
// })
|
271
|
-
// .catch((err) => {
|
272
|
-
// console.log(err);
|
273
|
-
// });
|
274
|
-
return [2 /*return*/, item];
|
275
|
-
}
|
276
|
-
});
|
277
|
-
}); };
|
278
|
-
this.update = function (item) { return __awaiter(_this, void 0, void 0, function () {
|
279
|
-
var newItem;
|
280
|
-
return __generator(this, function (_a) {
|
281
|
-
switch (_a.label) {
|
282
|
-
case 0:
|
283
|
-
newItem = this.setPropertiesForSharePointApi(item);
|
284
|
-
return [4 /*yield*/, this.repository.updateItem(newItem)];
|
285
|
-
case 1:
|
286
|
-
item = _a.sent();
|
287
|
-
// let newObject: any = {};
|
288
|
-
// var itemAsAny = item as any;
|
289
|
-
// Object.keys(itemAsAny).forEach((key) => {
|
290
|
-
// if ((key || "").toString().toLowerCase() != "id")
|
291
|
-
// newObject[key] = itemAsAny[key];
|
292
|
-
// });
|
293
|
-
// await this.context.graphClient
|
294
|
-
// .api(
|
295
|
-
// `/sites/${this.context.siteId}/lists/${this.listName}/items/${item.Id}/fields`
|
296
|
-
// )
|
297
|
-
// .update(newObject)
|
298
|
-
// .then((response: any) => {
|
299
|
-
// item = response;
|
300
|
-
// })
|
301
|
-
// .catch((err) => {
|
302
|
-
// console.log(err);
|
303
|
-
// });
|
304
|
-
return [2 /*return*/, item];
|
305
|
-
}
|
306
|
-
});
|
307
|
-
}); };
|
308
|
-
this.delete = function (id) { return __awaiter(_this, void 0, void 0, function () {
|
309
|
-
var result;
|
310
|
-
return __generator(this, function (_a) {
|
311
|
-
switch (_a.label) {
|
312
|
-
case 0: return [4 /*yield*/, this.repository.deleteItem(id)];
|
313
|
-
case 1:
|
314
|
-
result = _a.sent();
|
315
|
-
// await this.context.graphClient
|
316
|
-
// .api(`/sites/${this.context.siteId}/lists/${this.listName}/items/${id}`)
|
317
|
-
// .delete()
|
318
|
-
// .then((response: any) => {
|
319
|
-
// result = true;
|
320
|
-
// })
|
321
|
-
// .catch((err) => {
|
322
|
-
// console.log(err);
|
323
|
-
// });
|
324
|
-
return [2 /*return*/, result];
|
325
|
-
}
|
326
|
-
});
|
327
|
-
}); };
|
328
|
-
// getItems = async (
|
329
|
-
// filter?: string[],
|
330
|
-
// orderby?: string,
|
331
|
-
// top?: number
|
332
|
-
// ): Promise<T[]> => {
|
333
|
-
// let items: T[] = [];
|
334
|
-
// var expandFields = (
|
335
|
-
// [...this.lookUpFields, ...this.userTypeFields] || []
|
336
|
-
// ).join(",");
|
337
|
-
// try {
|
338
|
-
// var selectFields = this.getSelectFieldsForGraphApi();
|
339
|
-
// await this.context.graphClient
|
340
|
-
// .api(
|
341
|
-
// `/sites/${this.context.siteId}/lists/${
|
342
|
-
// this.listName
|
343
|
-
// }/items?expand=fields(select=${selectFields})&top=${top || this.top}`
|
344
|
-
// )
|
345
|
-
// .get((err, res) => {
|
346
|
-
// if (err) {
|
347
|
-
// console.log(err);
|
348
|
-
// return items;
|
349
|
-
// }
|
350
|
-
// if (
|
351
|
-
// res != undefined &&
|
352
|
-
// res["@odata.context"] != undefined &&
|
353
|
-
// res.value != undefined &&
|
354
|
-
// res.value.length > 0
|
355
|
-
// ) {
|
356
|
-
// console.log(res.value);
|
357
|
-
// for (var i = 0; i < res.value.length; i++) {
|
358
|
-
// var item = {
|
359
|
-
// Id: res.value[i].id,
|
360
|
-
// Title: res.value[i].fields["Title"],
|
361
|
-
// };
|
362
|
-
// items.push(item as T);
|
363
|
-
// }
|
364
|
-
// console.log(items);
|
365
|
-
// }
|
366
|
-
// });
|
367
|
-
// } catch {
|
368
|
-
// var selectFields = this.getSelectFieldsForSharePointApi();
|
369
|
-
// items = await this.repository.getAll(selectFields, expandFields);
|
370
|
-
// console.log(items);
|
371
|
-
// }
|
372
|
-
// this.items = items;
|
373
|
-
// return items;
|
374
|
-
// };
|
375
|
-
// getItemById = async (id: number): Promise<T> => {
|
376
|
-
// var item: any;
|
377
|
-
// try {
|
378
|
-
// await this.context.graphClient
|
379
|
-
// .api(`/sites/${this.context.siteId}/lists/${this.listName}/items/${id}`)
|
380
|
-
// .get()
|
381
|
-
// .then((response: any) => {
|
382
|
-
// // console.log(response);
|
383
|
-
// item = response.fields;
|
384
|
-
// })
|
385
|
-
// .catch((err) => {
|
386
|
-
// console.log(err);
|
387
|
-
// });
|
388
|
-
// } catch {
|
389
|
-
// item = await this.repository.getItemById(id);
|
390
|
-
// }
|
391
|
-
// return item;
|
392
|
-
// };
|
393
|
-
this.setPropertiesForSharePointApi = function (item) {
|
394
|
-
var newItem = {};
|
395
|
-
Object.keys(item).forEach(function (e) {
|
396
|
-
// console.log(`key=${e} value=${item[e]}`);
|
397
|
-
var keyText = (e || "").split("Lookup").join("");
|
398
|
-
newItem[keyText] = item[e];
|
399
|
-
});
|
400
|
-
return newItem;
|
401
|
-
};
|
402
|
-
this.getSelectFieldsForSharePointApi = function () {
|
403
|
-
var selectFields = "";
|
404
|
-
var userTypeFields = [];
|
405
|
-
var lookUpFields = [];
|
406
|
-
var additionalExpandFields = [];
|
407
|
-
if (_this.userTypeFields.length > 0) {
|
408
|
-
for (var i = 0; i < _this.userTypeFields.length; i++) {
|
409
|
-
userTypeFields.push("".concat(_this.userTypeFields[i], "Id"));
|
410
|
-
userTypeFields.push("".concat(_this.userTypeFields[i], "/Id"));
|
411
|
-
userTypeFields.push("".concat(_this.userTypeFields[i], "/Name"));
|
412
|
-
userTypeFields.push("".concat(_this.userTypeFields[i], "/Title"));
|
413
|
-
userTypeFields.push("".concat(_this.userTypeFields[i], "/EMail"));
|
414
|
-
}
|
415
|
-
}
|
416
|
-
if (_this.lookUpFields.length > 0) {
|
417
|
-
for (var i = 0; i < _this.lookUpFields.length; i++) {
|
418
|
-
lookUpFields.push("".concat(_this.lookUpFields[i]));
|
419
|
-
lookUpFields.push("".concat(_this.lookUpFields[i], "Id"));
|
420
|
-
lookUpFields.push("".concat(_this.lookUpFields[i], "/Id"));
|
421
|
-
lookUpFields.push("".concat(_this.lookUpFields[i], "/Title"));
|
422
|
-
}
|
423
|
-
}
|
424
|
-
if (_this.additionalExpandFields.length > 0) {
|
425
|
-
for (var i = 0; i < _this.additionalExpandFields.length; i++) {
|
426
|
-
additionalExpandFields.push(_this.additionalExpandFields[i]);
|
427
|
-
}
|
428
|
-
}
|
429
|
-
selectFields = (__spreadArray(__spreadArray(__spreadArray(__spreadArray([], _this.simpleFields, true), userTypeFields, true), lookUpFields, true), additionalExpandFields, true) || []).join(",");
|
430
|
-
return selectFields;
|
431
|
-
};
|
432
|
-
this.getSelectFieldsForGraphApi = function () {
|
433
|
-
var selectFields = "";
|
434
|
-
var userTypeFields = [];
|
435
|
-
var lookUpFields = [];
|
436
|
-
if (_this.userTypeFields.length > 0) {
|
437
|
-
for (var i = 0; i < _this.userTypeFields.length; i++) {
|
438
|
-
userTypeFields.push("".concat(_this.userTypeFields[0], "LookupId"));
|
439
|
-
userTypeFields.push("".concat(_this.userTypeFields[0]));
|
440
|
-
userTypeFields.push("".concat(_this.userTypeFields[0], "EMail"));
|
441
|
-
}
|
442
|
-
}
|
443
|
-
if (_this.lookUpFields.length > 0) {
|
444
|
-
for (var i = 0; i < _this.lookUpFields.length; i++) {
|
445
|
-
lookUpFields.push("".concat(_this.lookUpFields[0]));
|
446
|
-
lookUpFields.push("".concat(_this.lookUpFields[0], "LookupId"));
|
447
|
-
}
|
448
|
-
}
|
449
|
-
selectFields = (__spreadArray(__spreadArray(__spreadArray([], _this.simpleFields, true), userTypeFields, true), lookUpFields, true) || []).join(",");
|
450
|
-
return selectFields;
|
451
|
-
};
|
452
|
-
this.context = jitzContext;
|
453
|
-
this.listName = listName;
|
454
|
-
this.listGuid = listGuid;
|
455
|
-
this.simpleFields = simpleFields || [];
|
456
|
-
this.userTypeFields = userTypeFields || [];
|
457
|
-
this.lookUpFields = lookUpFields || [];
|
458
|
-
this.additionalExpandFields = additionalExpandFields || [];
|
459
|
-
this.repository = new Repository_1.default(this.context.spContext, listName, listGuid);
|
460
|
-
}
|
461
|
-
List.prototype.loadMoreIndexed = function () {
|
462
|
-
return __awaiter(this, void 0, void 0, function () {
|
463
|
-
var response, filter, results;
|
464
|
-
return __generator(this, function (_a) {
|
465
|
-
switch (_a.label) {
|
466
|
-
case 0:
|
467
|
-
if (!(this._nextPageLink != undefined && this._nextPageLink.length > 0)) return [3 /*break*/, 2];
|
468
|
-
return [4 /*yield*/, this.repository.getAllFromUrl(this._nextPageLink)];
|
469
|
-
case 1:
|
470
|
-
response = _a.sent();
|
471
|
-
this._nextPageLink = response.__next || "";
|
472
|
-
return [2 /*return*/, response.results];
|
473
|
-
case 2:
|
474
|
-
filter = "";
|
475
|
-
this.upperId = this.lowerId;
|
476
|
-
this.lowerId = this.getLowerId(this.upperId);
|
477
|
-
if (!(this.upperId > 1)) return [3 /*break*/, 4];
|
478
|
-
filter = "(Id gt ".concat(this.lowerId, " and Id le ").concat(this.upperId, ")");
|
479
|
-
if (this.filters != undefined && this.filters.length > 0)
|
480
|
-
filter = "".concat(filter, " and ").concat(this.filters);
|
481
|
-
return [4 /*yield*/, this.getData(filter)];
|
482
|
-
case 3:
|
483
|
-
results = _a.sent();
|
484
|
-
return [2 /*return*/, results];
|
485
|
-
case 4: return [2 /*return*/, []];
|
486
|
-
}
|
487
|
-
});
|
488
|
-
});
|
489
|
-
};
|
490
|
-
return List;
|
491
|
-
}());
|
492
|
-
exports.default = List;
|
@@ -1,22 +0,0 @@
|
|
1
|
-
import IJitzSPContext from "../interfaces/IJitzSPContext";
|
2
|
-
import { IModel } from "../interfaces/IModels";
|
3
|
-
import { IRepository } from "../interfaces/IRepository";
|
4
|
-
export default class Repository<T extends IModel> implements IRepository<T> {
|
5
|
-
private _listEntityType?;
|
6
|
-
context: IJitzSPContext;
|
7
|
-
listName: string;
|
8
|
-
listGuid: string;
|
9
|
-
listUrl: string;
|
10
|
-
constructor(context: IJitzSPContext, listName: string, listGuid?: string);
|
11
|
-
getAll(selectFields?: string, expand?: string, filters?: string, orderBy?: string, top?: number, skip?: number, skipTokenUniqueField?: string, skipTokenUniqueFieldValue?: string): Promise<T[]>;
|
12
|
-
getAllFromUrl(url: string): Promise<T[]>;
|
13
|
-
getAllRecursive(selectFields?: string, expand?: string, filters?: string, orderBy?: string, top?: number, maxRecursiveCount?: number): Promise<T[]>;
|
14
|
-
private recursiveFetch;
|
15
|
-
itemsCount(filters?: string): any;
|
16
|
-
getItemById(id: number, selectFields?: string, expand?: string): Promise<T>;
|
17
|
-
createItem(item: T): Promise<T>;
|
18
|
-
updateItem(item: T): Promise<T>;
|
19
|
-
deleteItem(id: number): Promise<boolean>;
|
20
|
-
deleteItems(ids: number[]): Promise<boolean>;
|
21
|
-
private getEntityType;
|
22
|
-
}
|