jitz-sharepoint-utilities 2.0.7 → 2.0.9
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/List.ts +9 -2
- package/data/context/Repository.ts +23 -24
- package/data/interfaces/IRepository.ts +2 -0
- package/lib/data/context/List.d.ts +2 -1
- package/lib/data/context/List.js +4 -2
- package/lib/data/context/Repository.d.ts +3 -1
- package/lib/data/context/Repository.js +15 -18
- package/lib/data/interfaces/IRepository.d.ts +2 -0
- package/package.json +1 -1
package/data/context/List.ts
CHANGED
@@ -11,6 +11,7 @@ interface BigObject<T> {
|
|
11
11
|
export default class List<T extends IModel> implements IList<T> {
|
12
12
|
context: IJitzContext;
|
13
13
|
listName: string;
|
14
|
+
listGuid: string;
|
14
15
|
// _listId: string;
|
15
16
|
_nextPageLink: string;
|
16
17
|
// items: any[];
|
@@ -33,15 +34,21 @@ export default class List<T extends IModel> implements IList<T> {
|
|
33
34
|
simpleFields: string[],
|
34
35
|
userTypeFields: string[],
|
35
36
|
lookUpFields: string[],
|
36
|
-
additionalExpandFields: string[]
|
37
|
+
additionalExpandFields: string[],
|
38
|
+
listGuid: string = ""
|
37
39
|
) {
|
38
40
|
this.context = jitzContext;
|
39
41
|
this.listName = listName;
|
42
|
+
this.listGuid = listGuid;
|
40
43
|
this.simpleFields = simpleFields || [];
|
41
44
|
this.userTypeFields = userTypeFields || [];
|
42
45
|
this.lookUpFields = lookUpFields || [];
|
43
46
|
this.additionalExpandFields = additionalExpandFields || [];
|
44
|
-
this.repository = new Repository<T>(
|
47
|
+
this.repository = new Repository<T>(
|
48
|
+
this.context.spContext,
|
49
|
+
listName,
|
50
|
+
listGuid
|
51
|
+
);
|
45
52
|
}
|
46
53
|
|
47
54
|
getItems = async (
|
@@ -7,10 +7,22 @@ export default class Repository<T extends IModel> implements IRepository<T> {
|
|
7
7
|
private _listEntityType?: string;
|
8
8
|
public context: IJitzSPContext;
|
9
9
|
public listName: string;
|
10
|
-
|
11
|
-
|
10
|
+
public listGuid: string;
|
11
|
+
public listUrl: string;
|
12
|
+
|
13
|
+
constructor(
|
14
|
+
context: IJitzSPContext,
|
15
|
+
listName: string,
|
16
|
+
listGuid: string = ""
|
17
|
+
) {
|
12
18
|
this.context = context;
|
13
19
|
this.listName = listName;
|
20
|
+
this.listGuid = listGuid;
|
21
|
+
this.listUrl = `${this.context.siteUrl}/_api/web/lists/${
|
22
|
+
this.listGuid == ""
|
23
|
+
? "GetByTitle('" + this.listName + "')"
|
24
|
+
: "lists(guid'" + this.listGuid + "')"
|
25
|
+
}`;
|
14
26
|
}
|
15
27
|
|
16
28
|
public getAll(
|
@@ -23,10 +35,7 @@ export default class Repository<T extends IModel> implements IRepository<T> {
|
|
23
35
|
skipTokenUniqueField?: string,
|
24
36
|
skipTokenUniqueFieldValue?: string
|
25
37
|
): Promise<T[]> {
|
26
|
-
let queryUrlGetAllItems: string =
|
27
|
-
`${this.context.siteUrl}/_api/web/lists/GetByTitle('` +
|
28
|
-
this.listName +
|
29
|
-
`')/items`;
|
38
|
+
let queryUrlGetAllItems: string = `${this.listUrl}/items`;
|
30
39
|
|
31
40
|
if (selectFields != null && selectFields != "") {
|
32
41
|
queryUrlGetAllItems = queryUrlGetAllItems + `?$select=` + selectFields;
|
@@ -122,10 +131,7 @@ export default class Repository<T extends IModel> implements IRepository<T> {
|
|
122
131
|
maxRecursiveCount = 5
|
123
132
|
): Promise<T[]> {
|
124
133
|
let items: T[] = [];
|
125
|
-
let queryUrlGetAllItems: string =
|
126
|
-
`${this.context.siteUrl}/_api/web/lists/GetByTitle('` +
|
127
|
-
this.listName +
|
128
|
-
`')/items`;
|
134
|
+
let queryUrlGetAllItems: string = `${this.listUrl}/items`;
|
129
135
|
|
130
136
|
if (selectFields != null && selectFields != "") {
|
131
137
|
queryUrlGetAllItems = queryUrlGetAllItems + `?$select=` + selectFields;
|
@@ -230,10 +236,7 @@ export default class Repository<T extends IModel> implements IRepository<T> {
|
|
230
236
|
}
|
231
237
|
|
232
238
|
public itemsCount(filters?: string) {
|
233
|
-
let queryUrlGetAllItems: string =
|
234
|
-
`${this.context.siteUrl}/_api/web/lists/GetByTitle('` +
|
235
|
-
this.listName +
|
236
|
-
`')/ItemCount`;
|
239
|
+
let queryUrlGetAllItems: string = `${this.listUrl}/ItemCount`;
|
237
240
|
|
238
241
|
if (filters != null && filters != "") {
|
239
242
|
queryUrlGetAllItems = queryUrlGetAllItems + `?$filter=` + filters;
|
@@ -263,9 +266,7 @@ export default class Repository<T extends IModel> implements IRepository<T> {
|
|
263
266
|
expand?: string
|
264
267
|
): Promise<T> {
|
265
268
|
const queryUrl: string =
|
266
|
-
`${this.
|
267
|
-
this.listName +
|
268
|
-
`')/items(` +
|
269
|
+
`${this.listUrl}/items(` +
|
269
270
|
id +
|
270
271
|
`)` +
|
271
272
|
`?$select=*${selectFields != undefined ? `,${selectFields}` : ""}` +
|
@@ -294,7 +295,7 @@ export default class Repository<T extends IModel> implements IRepository<T> {
|
|
294
295
|
item.__metadata = {
|
295
296
|
type: entityType,
|
296
297
|
};
|
297
|
-
var requestUrl = `${this.
|
298
|
+
var requestUrl = `${this.listUrl}/items`;
|
298
299
|
return this.context.client
|
299
300
|
.post(requestUrl, item, {
|
300
301
|
Accept: "application/json;odata=nometadata",
|
@@ -318,7 +319,7 @@ export default class Repository<T extends IModel> implements IRepository<T> {
|
|
318
319
|
//etag: "1",
|
319
320
|
type: entityType,
|
320
321
|
};
|
321
|
-
var requestUrl = `${this.
|
322
|
+
var requestUrl = `${this.listUrl}/items(${item.Id})`;
|
322
323
|
return this.context.client
|
323
324
|
.post(requestUrl, item, {
|
324
325
|
Accept: "application/json;odata=nometadata",
|
@@ -339,7 +340,7 @@ export default class Repository<T extends IModel> implements IRepository<T> {
|
|
339
340
|
}
|
340
341
|
|
341
342
|
public deleteItem(id: number): Promise<boolean> {
|
342
|
-
var requestUrl = `${this.
|
343
|
+
var requestUrl = `${this.listUrl}/items(${id})`;
|
343
344
|
return this.context.client
|
344
345
|
.post(
|
345
346
|
requestUrl,
|
@@ -374,7 +375,7 @@ export default class Repository<T extends IModel> implements IRepository<T> {
|
|
374
375
|
|
375
376
|
ids.map((id) => {
|
376
377
|
// Request creation for first list item Delete
|
377
|
-
var endpoint = `${this.
|
378
|
+
var endpoint = `${this.listUrl}/items(${id})`;
|
378
379
|
|
379
380
|
// create the changeset
|
380
381
|
batchContents.push("--changeset_" + changeSetGUID);
|
@@ -453,9 +454,7 @@ export default class Repository<T extends IModel> implements IRepository<T> {
|
|
453
454
|
}
|
454
455
|
|
455
456
|
this.context.client
|
456
|
-
.get(
|
457
|
-
`${this.context.siteUrl}/_api/web/lists/getbytitle('${this.listName}')?$select=ListItemEntityTypeFullName`
|
458
|
-
)
|
457
|
+
.get(`${this.listUrl}?$select=ListItemEntityTypeFullName`)
|
459
458
|
.then(
|
460
459
|
(
|
461
460
|
response: any
|
@@ -5,6 +5,7 @@ import { IRepository } from "../interfaces/IRepository";
|
|
5
5
|
export default class List<T extends IModel> implements IList<T> {
|
6
6
|
context: IJitzContext;
|
7
7
|
listName: string;
|
8
|
+
listGuid: string;
|
8
9
|
_nextPageLink: string;
|
9
10
|
top: number;
|
10
11
|
indexLimit: number;
|
@@ -17,7 +18,7 @@ export default class List<T extends IModel> implements IList<T> {
|
|
17
18
|
upperId: number;
|
18
19
|
lowerId: number;
|
19
20
|
orderBy?: string | undefined;
|
20
|
-
constructor(jitzContext: IJitzContext, listName: string, simpleFields: string[], userTypeFields: string[], lookUpFields: string[], additionalExpandFields: string[]);
|
21
|
+
constructor(jitzContext: IJitzContext, listName: string, simpleFields: string[], userTypeFields: string[], lookUpFields: string[], additionalExpandFields: string[], listGuid?: string);
|
21
22
|
getItems: (filters?: string, orderby?: string, top?: number, skip?: number) => Promise<T[]>;
|
22
23
|
loadMore: () => Promise<T[]>;
|
23
24
|
getItemsIndexed: (filterQuery?: string, orderby?: string, top?: number) => Promise<T[]>;
|
package/lib/data/context/List.js
CHANGED
@@ -47,7 +47,8 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
47
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
48
48
|
var Repository_1 = require("./Repository");
|
49
49
|
var List = /** @class */ (function () {
|
50
|
-
function List(jitzContext, listName, simpleFields, userTypeFields, lookUpFields, additionalExpandFields) {
|
50
|
+
function List(jitzContext, listName, simpleFields, userTypeFields, lookUpFields, additionalExpandFields, listGuid) {
|
51
|
+
if (listGuid === void 0) { listGuid = ""; }
|
51
52
|
var _this = this;
|
52
53
|
// items: any[];
|
53
54
|
this.top = 100;
|
@@ -450,11 +451,12 @@ var List = /** @class */ (function () {
|
|
450
451
|
};
|
451
452
|
this.context = jitzContext;
|
452
453
|
this.listName = listName;
|
454
|
+
this.listGuid = listGuid;
|
453
455
|
this.simpleFields = simpleFields || [];
|
454
456
|
this.userTypeFields = userTypeFields || [];
|
455
457
|
this.lookUpFields = lookUpFields || [];
|
456
458
|
this.additionalExpandFields = additionalExpandFields || [];
|
457
|
-
this.repository = new Repository_1.default(this.context.spContext, listName);
|
459
|
+
this.repository = new Repository_1.default(this.context.spContext, listName, listGuid);
|
458
460
|
}
|
459
461
|
List.prototype.loadMoreIndexed = function () {
|
460
462
|
return __awaiter(this, void 0, void 0, function () {
|
@@ -5,7 +5,9 @@ export default class Repository<T extends IModel> implements IRepository<T> {
|
|
5
5
|
private _listEntityType?;
|
6
6
|
context: IJitzSPContext;
|
7
7
|
listName: string;
|
8
|
-
|
8
|
+
listGuid: string;
|
9
|
+
listUrl: string;
|
10
|
+
constructor(context: IJitzSPContext, listName: string, listGuid?: string);
|
9
11
|
getAll(selectFields?: string, expand?: string, filters?: string, orderBy?: string, top?: number, skip?: number, skipTokenUniqueField?: string, skipTokenUniqueFieldValue?: string): Promise<T[]>;
|
10
12
|
getAllFromUrl(url: string): Promise<T[]>;
|
11
13
|
getAllRecursive(selectFields?: string, expand?: string, filters?: string, orderBy?: string, top?: number, maxRecursiveCount?: number): Promise<T[]>;
|
@@ -38,14 +38,17 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
39
39
|
var UtilityService_1 = require("../../services/UtilityService");
|
40
40
|
var Repository = /** @class */ (function () {
|
41
|
-
function Repository(context, listName) {
|
41
|
+
function Repository(context, listName, listGuid) {
|
42
|
+
if (listGuid === void 0) { listGuid = ""; }
|
42
43
|
this.context = context;
|
43
44
|
this.listName = listName;
|
45
|
+
this.listGuid = listGuid;
|
46
|
+
this.listUrl = "".concat(this.context.siteUrl, "/_api/web/lists/").concat(this.listGuid == ""
|
47
|
+
? "GetByTitle('" + this.listName + "')"
|
48
|
+
: "lists(guid'" + this.listGuid + "')");
|
44
49
|
}
|
45
50
|
Repository.prototype.getAll = function (selectFields, expand, filters, orderBy, top, skip, skipTokenUniqueField, skipTokenUniqueFieldValue) {
|
46
|
-
var queryUrlGetAllItems = "".concat(this.
|
47
|
-
this.listName +
|
48
|
-
"')/items";
|
51
|
+
var queryUrlGetAllItems = "".concat(this.listUrl, "/items");
|
49
52
|
if (selectFields != null && selectFields != "") {
|
50
53
|
queryUrlGetAllItems = queryUrlGetAllItems + "?$select=" + selectFields;
|
51
54
|
}
|
@@ -138,9 +141,7 @@ var Repository = /** @class */ (function () {
|
|
138
141
|
switch (_a.label) {
|
139
142
|
case 0:
|
140
143
|
items = [];
|
141
|
-
queryUrlGetAllItems = "".concat(this.
|
142
|
-
this.listName +
|
143
|
-
"')/items";
|
144
|
+
queryUrlGetAllItems = "".concat(this.listUrl, "/items");
|
144
145
|
if (selectFields != null && selectFields != "") {
|
145
146
|
queryUrlGetAllItems = queryUrlGetAllItems + "?$select=" + selectFields;
|
146
147
|
}
|
@@ -268,9 +269,7 @@ var Repository = /** @class */ (function () {
|
|
268
269
|
});
|
269
270
|
};
|
270
271
|
Repository.prototype.itemsCount = function (filters) {
|
271
|
-
var queryUrlGetAllItems = "".concat(this.
|
272
|
-
this.listName +
|
273
|
-
"')/ItemCount";
|
272
|
+
var queryUrlGetAllItems = "".concat(this.listUrl, "/ItemCount");
|
274
273
|
if (filters != null && filters != "") {
|
275
274
|
queryUrlGetAllItems = queryUrlGetAllItems + "?$filter=" + filters;
|
276
275
|
}
|
@@ -298,9 +297,7 @@ var Repository = /** @class */ (function () {
|
|
298
297
|
return __generator(this, function (_a) {
|
299
298
|
switch (_a.label) {
|
300
299
|
case 0:
|
301
|
-
queryUrl = "".concat(this.
|
302
|
-
this.listName +
|
303
|
-
"')/items(" +
|
300
|
+
queryUrl = "".concat(this.listUrl, "/items(") +
|
304
301
|
id +
|
305
302
|
")" +
|
306
303
|
"?$select=*".concat(selectFields != undefined ? ",".concat(selectFields) : "") +
|
@@ -333,7 +330,7 @@ var Repository = /** @class */ (function () {
|
|
333
330
|
item.__metadata = {
|
334
331
|
type: entityType,
|
335
332
|
};
|
336
|
-
var requestUrl = "".concat(_this.
|
333
|
+
var requestUrl = "".concat(_this.listUrl, "/items");
|
337
334
|
return _this.context.client
|
338
335
|
.post(requestUrl, item, {
|
339
336
|
Accept: "application/json;odata=nometadata",
|
@@ -358,7 +355,7 @@ var Repository = /** @class */ (function () {
|
|
358
355
|
//etag: "1",
|
359
356
|
type: entityType,
|
360
357
|
};
|
361
|
-
var requestUrl = "".concat(_this.
|
358
|
+
var requestUrl = "".concat(_this.listUrl, "/items(").concat(item.Id, ")");
|
362
359
|
return _this.context.client
|
363
360
|
.post(requestUrl, item, {
|
364
361
|
Accept: "application/json;odata=nometadata",
|
@@ -379,7 +376,7 @@ var Repository = /** @class */ (function () {
|
|
379
376
|
});
|
380
377
|
};
|
381
378
|
Repository.prototype.deleteItem = function (id) {
|
382
|
-
var requestUrl = "".concat(this.
|
379
|
+
var requestUrl = "".concat(this.listUrl, "/items(").concat(id, ")");
|
383
380
|
return this.context.client
|
384
381
|
.post(requestUrl, {}, {
|
385
382
|
Accept: "application/json;odata=nometadata",
|
@@ -408,7 +405,7 @@ var Repository = /** @class */ (function () {
|
|
408
405
|
var batchContents = new Array();
|
409
406
|
ids.map(function (id) {
|
410
407
|
// Request creation for first list item Delete
|
411
|
-
var endpoint = "".concat(_this.
|
408
|
+
var endpoint = "".concat(_this.listUrl, "/items(").concat(id, ")");
|
412
409
|
// create the changeset
|
413
410
|
batchContents.push("--changeset_" + changeSetGUID);
|
414
411
|
batchContents.push("Content-Type: application/http");
|
@@ -472,7 +469,7 @@ var Repository = /** @class */ (function () {
|
|
472
469
|
return;
|
473
470
|
}
|
474
471
|
_this.context.client
|
475
|
-
.get("".concat(_this.
|
472
|
+
.get("".concat(_this.listUrl, "?$select=ListItemEntityTypeFullName"))
|
476
473
|
.then(function (response) {
|
477
474
|
return response;
|
478
475
|
}, function (error) {
|
@@ -3,6 +3,8 @@ import { IModel } from "./IModels";
|
|
3
3
|
export interface IRepository<T extends IModel> {
|
4
4
|
context: IJitzSPContext;
|
5
5
|
listName: string;
|
6
|
+
listGuid: string;
|
7
|
+
listUrl: string;
|
6
8
|
getAll(selectFields?: string, expand?: string, filters?: string, orderBy?: string, top?: number, skip?: number, skipTokenUniqueField?: string, skipTokenUniqueFieldValue?: string): Promise<T[]>;
|
7
9
|
getAllFromUrl(url: string): Promise<T[]>;
|
8
10
|
itemsCount(filters?: string): Promise<number>;
|