gd-sprest 8.4.4 → 8.4.6
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/@types/v2/drive.d.ts +1 -1
- package/@types/v2/drives.d.ts +2 -1
- package/@types/v2/sites.d.ts +6 -3
- package/build/mapper/v2.js +10 -0
- package/build/rest.js +1 -1
- package/build/utils/request.js +19 -10
- package/build/v2/drive.js +6 -3
- package/build/v2/drives.js +6 -3
- package/build/v2/sites.js +64 -2
- package/dist/gd-sprest.d.ts +9 -5
- package/dist/gd-sprest.js +1 -1
- package/dist/gd-sprest.min.js +1 -1
- package/package.json +2 -2
package/@types/v2/drive.d.ts
CHANGED
|
@@ -29,5 +29,5 @@ export interface Idrive {
|
|
|
29
29
|
* @param siteId - (Optional) The site id to target, current by default.
|
|
30
30
|
* @param targetInfo - (Optional) The target information.
|
|
31
31
|
*/
|
|
32
|
-
(props?: { siteId?: string, targetInfo?: ITargetInfoProps }): IBaseExecution<drive>;
|
|
32
|
+
(props?: { siteId?: string, siteUrl?: string, targetInfo?: ITargetInfoProps }): IBaseExecution<drive>;
|
|
33
33
|
}
|
package/@types/v2/drives.d.ts
CHANGED
|
@@ -28,7 +28,8 @@ export interface Idrives {
|
|
|
28
28
|
* Get the libraries for a site.
|
|
29
29
|
* @param id - (Optional) The drive id to target.
|
|
30
30
|
* @param siteId - (Optional) The site id to target, current by default.
|
|
31
|
+
* @param siteUrl - (Optional) The site url to target, current by default.
|
|
31
32
|
* @param targetInfo - (Optional) The target information.
|
|
32
33
|
*/
|
|
33
|
-
(props?: { driveId?: string, siteId?: string, targetInfo?: ITargetInfoProps }): IBaseExecution<driveCollection>;
|
|
34
|
+
(props?: { driveId?: string, siteId?: string, siteUrl?: string, targetInfo?: ITargetInfoProps }): IBaseExecution<driveCollection>;
|
|
34
35
|
}
|
package/@types/v2/sites.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export const sites: Isites;
|
|
|
27
27
|
export interface Isites {
|
|
28
28
|
/**
|
|
29
29
|
* Creates an instance of the site library.
|
|
30
|
-
* @param
|
|
30
|
+
* @param siteId - (Optional) The site id to target, current by default.
|
|
31
31
|
* @param targetInfo - (Optional) The target information.
|
|
32
32
|
*/
|
|
33
33
|
(props?: { siteId?: string, targetInfo?: ITargetInfoProps }): siteMethods & sites;
|
|
@@ -35,6 +35,9 @@ export interface Isites {
|
|
|
35
35
|
/** Returns the current web. */
|
|
36
36
|
static getCurrentWeb(): IBaseExecution<sites> & siteMethods;
|
|
37
37
|
|
|
38
|
-
/** Returns a
|
|
39
|
-
static
|
|
38
|
+
/** Returns a drive for a site. */
|
|
39
|
+
static getDrive(props: { siteId?: string, siteUrl?: string, libName?: string }): IBaseExecution<list> & listMethods;
|
|
40
|
+
|
|
41
|
+
/** Returns a list for a site. */
|
|
42
|
+
static getList(props: { siteId?: string, siteUrl?: string, listId?: string, listName?: string }): IBaseExecution<list> & listMethods;
|
|
40
43
|
}
|
package/build/mapper/v2.js
CHANGED
|
@@ -128,6 +128,9 @@ exports.MapperV2 = {
|
|
|
128
128
|
query: { argNames: ["oData"], requestType: utils_1.RequestType.OData },
|
|
129
129
|
},
|
|
130
130
|
list: {
|
|
131
|
+
properties: [
|
|
132
|
+
"items|listItems|([Name])|listItem"
|
|
133
|
+
],
|
|
131
134
|
activities: {
|
|
132
135
|
requestType: utils_1.RequestType.Get
|
|
133
136
|
},
|
|
@@ -211,6 +214,9 @@ exports.MapperV2 = {
|
|
|
211
214
|
query: { argNames: ["oData"], requestType: utils_1.RequestType.OData },
|
|
212
215
|
},
|
|
213
216
|
lists: {
|
|
217
|
+
properties: [
|
|
218
|
+
"lists|lists|('[Name]')|list"
|
|
219
|
+
],
|
|
214
220
|
add: {
|
|
215
221
|
args: ["values"],
|
|
216
222
|
name: "",
|
|
@@ -267,6 +273,10 @@ exports.MapperV2 = {
|
|
|
267
273
|
query: { argNames: ["oData"], requestType: utils_1.RequestType.OData },
|
|
268
274
|
},
|
|
269
275
|
sites: {
|
|
276
|
+
properties: [
|
|
277
|
+
"drives|drives|('[Name]')|drive", "items|listItems|([Name])|listItem",
|
|
278
|
+
"lists|lists|('[Name]')|list"
|
|
279
|
+
],
|
|
270
280
|
add: {
|
|
271
281
|
args: ["values"],
|
|
272
282
|
name: "",
|
package/build/rest.js
CHANGED
package/build/utils/request.js
CHANGED
|
@@ -43,18 +43,20 @@ exports.Request = {
|
|
|
43
43
|
// Update the object type
|
|
44
44
|
objType = resultsObjType;
|
|
45
45
|
}
|
|
46
|
-
// Get the object type from the context
|
|
47
|
-
var metadataType = (obj["@odata.context"] || objType);
|
|
48
|
-
var values = metadataType.split("_api/v2.0/$metadata#");
|
|
49
|
-
if (values.length > 1) {
|
|
50
|
-
objType = values[1];
|
|
51
|
-
}
|
|
52
46
|
else {
|
|
53
|
-
|
|
54
|
-
|
|
47
|
+
// Get the object type from the context
|
|
48
|
+
var metadataType = (obj["@odata.context"] || objType);
|
|
49
|
+
var values = metadataType.split("_api/v2.0/$metadata#");
|
|
50
|
+
if (values.length > 1) {
|
|
51
|
+
objType = values[1];
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
values = metadataType.split("/");
|
|
55
|
+
objType = values[values.length - 1].split("?")[0];
|
|
56
|
+
}
|
|
57
|
+
// Update the object type if it's a single instance
|
|
58
|
+
objType = objType.replace("s/$entity", "");
|
|
55
59
|
}
|
|
56
|
-
// Update the object type if it's a single instance
|
|
57
|
-
objType = objType.replace("s/$entity", "");
|
|
58
60
|
// Get the methods for this object type
|
|
59
61
|
methods = mapper_1.MapperV2[objType];
|
|
60
62
|
console.log("[gd-sprest] v2 response detected. Type is: " + objType, methods);
|
|
@@ -149,6 +151,7 @@ exports.Request = {
|
|
|
149
151
|
},
|
|
150
152
|
// Method to add properties to the base object
|
|
151
153
|
addProperties: function (base, data) {
|
|
154
|
+
var isV2 = data["@odata.context"] ? true : false;
|
|
152
155
|
// Parse the data properties
|
|
153
156
|
for (var key in data) {
|
|
154
157
|
var value = data[key];
|
|
@@ -162,6 +165,12 @@ exports.Request = {
|
|
|
162
165
|
base["etag"] = value["etag"];
|
|
163
166
|
continue;
|
|
164
167
|
}
|
|
168
|
+
// See if this is the etag
|
|
169
|
+
if (key == "@odata.etag") {
|
|
170
|
+
// Set the etag value and continue
|
|
171
|
+
base["etag"] = value[key];
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
165
174
|
// See if the base is a collection property
|
|
166
175
|
if (value && value.__deferred && value.__deferred.uri) {
|
|
167
176
|
// Generate a method for the base property
|
package/build/v2/drive.js
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.drive = void 0;
|
|
4
|
-
var contextInfo_1 = require("../lib/contextInfo");
|
|
5
4
|
var utils_1 = require("../utils");
|
|
6
5
|
/**
|
|
7
6
|
* Drive
|
|
8
7
|
* Returns the default library for a site.
|
|
9
8
|
*/
|
|
10
9
|
exports.drive = (function (props) {
|
|
11
|
-
var _a;
|
|
12
10
|
if (props === void 0) { props = {}; }
|
|
13
11
|
var drive = new utils_1.Base(props.targetInfo);
|
|
14
12
|
// Default the properties
|
|
15
13
|
drive.targetInfo.defaultToWebFl = true;
|
|
16
14
|
drive.targetInfo.requestType = utils_1.RequestType.GraphGet;
|
|
15
|
+
// See if the web url exists
|
|
16
|
+
if (props.siteUrl) {
|
|
17
|
+
// Set the settings
|
|
18
|
+
drive.targetInfo.url = props.siteUrl;
|
|
19
|
+
}
|
|
17
20
|
// See if an endpoint is not defined
|
|
18
21
|
if (drive.targetInfo.endpoint == undefined) {
|
|
19
22
|
// Default the endpoint
|
|
20
|
-
drive.targetInfo.endpoint = "_api/v2.0/
|
|
23
|
+
drive.targetInfo.endpoint = "_api/v2.0/" + (props.siteId ? "sites/" + props.siteId.replace(/[{}]/g, '') : "") + "drive";
|
|
21
24
|
// Add the methods
|
|
22
25
|
utils_1.Request.addMethods(drive, { __metadata: { type: "@odata.context/_api/v2.0/$metadata#drive" } });
|
|
23
26
|
}
|
package/build/v2/drives.js
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.drives = void 0;
|
|
4
|
-
var contextInfo_1 = require("../lib/contextInfo");
|
|
5
4
|
var utils_1 = require("../utils");
|
|
6
5
|
/**
|
|
7
6
|
* Drives
|
|
8
7
|
* Returns the libraries for a site.
|
|
9
8
|
*/
|
|
10
9
|
exports.drives = (function (props) {
|
|
11
|
-
var _a;
|
|
12
10
|
if (props === void 0) { props = {}; }
|
|
13
11
|
var drives = new utils_1.Base(props.targetInfo);
|
|
14
12
|
// Default the properties
|
|
15
13
|
drives.targetInfo.defaultToWebFl = true;
|
|
16
14
|
drives.targetInfo.requestType = utils_1.RequestType.GraphGet;
|
|
15
|
+
// See if the web url exists
|
|
16
|
+
if (props.siteUrl) {
|
|
17
|
+
// Set the settings
|
|
18
|
+
drives.targetInfo.url = props.siteUrl;
|
|
19
|
+
}
|
|
17
20
|
// See if an endpoint is not defined
|
|
18
21
|
if (drives.targetInfo.endpoint == undefined) {
|
|
19
22
|
// Default the endpoint
|
|
20
|
-
drives.targetInfo.endpoint = "_api/v2.0/
|
|
23
|
+
drives.targetInfo.endpoint = "_api/v2.0/" + (props.siteId ? "sites/" + props.siteId.replace(/[{}]/g, '') : "") + "drives";
|
|
21
24
|
// See if the drive id was provided
|
|
22
25
|
if (props.driveId) {
|
|
23
26
|
// Append the id
|
package/build/v2/sites.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.sites = void 0;
|
|
4
4
|
var contextInfo_1 = require("../lib/contextInfo");
|
|
5
|
+
var site_1 = require("../lib/site");
|
|
5
6
|
var utils_1 = require("../utils");
|
|
6
7
|
/**
|
|
7
8
|
* Sites
|
|
@@ -22,5 +23,66 @@ exports.sites = (function (props) {
|
|
|
22
23
|
});
|
|
23
24
|
/** Returns the current web. */
|
|
24
25
|
exports.sites.getCurrentWeb = function () { return exports.sites().sites(contextInfo_1.ContextInfo.webId.replace(/^\{|\}$/g, '')); };
|
|
25
|
-
/** Returns a
|
|
26
|
-
exports.sites.
|
|
26
|
+
/** Returns a drive */
|
|
27
|
+
exports.sites.getDrive = (function (props) {
|
|
28
|
+
// Return a promise
|
|
29
|
+
return new Promise(function (resolve, reject) {
|
|
30
|
+
// Method to get the drive id
|
|
31
|
+
var getDriveId = function (siteId, libName) {
|
|
32
|
+
// Return a promise
|
|
33
|
+
return new Promise(function (resolve, reject) {
|
|
34
|
+
// Get the drives
|
|
35
|
+
exports.sites({ siteId: siteId }).drives().query({ Select: ["id", "name"] }).execute(function (drives) {
|
|
36
|
+
// Parse the drives
|
|
37
|
+
for (var i = 0; i < drives.results.length; i++) {
|
|
38
|
+
var drive = drives.results[i];
|
|
39
|
+
// See if this is the target library
|
|
40
|
+
if (drive["name"] == libName) {
|
|
41
|
+
// Resolve the request
|
|
42
|
+
resolve(drive.id);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// Not found
|
|
47
|
+
reject();
|
|
48
|
+
}, reject);
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
// See if the site id exists
|
|
52
|
+
if (props.siteId) {
|
|
53
|
+
// Get the drive id
|
|
54
|
+
getDriveId(props.siteId, props.libName).then(function (driveId) {
|
|
55
|
+
// Resolve the request
|
|
56
|
+
resolve(exports.sites({ siteId: props.siteId }).drives(driveId));
|
|
57
|
+
}, reject);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
// Get the site
|
|
61
|
+
site_1.Site(props.siteUrl).query({ Select: ["Id"] }).execute(function (site) {
|
|
62
|
+
// Get the drive id
|
|
63
|
+
getDriveId(site.Id, props.libName).then(function (driveId) {
|
|
64
|
+
// Resolve the request
|
|
65
|
+
resolve(exports.sites({ siteId: site.Id }).drives(driveId));
|
|
66
|
+
}, reject);
|
|
67
|
+
}, reject);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
/** Returns a list */
|
|
72
|
+
exports.sites.getList = (function (props) {
|
|
73
|
+
// Return a promise
|
|
74
|
+
return new Promise(function (resolve, reject) {
|
|
75
|
+
// See if the site id exists
|
|
76
|
+
if (props.siteId) {
|
|
77
|
+
// Resolve the request
|
|
78
|
+
resolve(exports.sites({ siteId: props.siteId }).lists(props.listId || props.listName));
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
// Get the site
|
|
82
|
+
site_1.Site(props.siteUrl).query({ Select: ["Id"] }).execute(function (site) {
|
|
83
|
+
// Resolve the request
|
|
84
|
+
resolve(exports.sites({ siteId: site.Id }).lists(props.listId || props.listName));
|
|
85
|
+
}, reject);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
});
|
package/dist/gd-sprest.d.ts
CHANGED
|
@@ -4468,7 +4468,7 @@ declare module 'gd-sprest/v2/drive' {
|
|
|
4468
4468
|
* @param siteId - (Optional) The site id to target, current by default.
|
|
4469
4469
|
* @param targetInfo - (Optional) The target information.
|
|
4470
4470
|
*/
|
|
4471
|
-
(props?: { siteId?: string, targetInfo?: ITargetInfoProps }): IBaseExecution<drive>;
|
|
4471
|
+
(props?: { siteId?: string, siteUrl?: string, targetInfo?: ITargetInfoProps }): IBaseExecution<drive>;
|
|
4472
4472
|
}
|
|
4473
4473
|
}
|
|
4474
4474
|
|
|
@@ -4503,9 +4503,10 @@ declare module 'gd-sprest/v2/drives' {
|
|
|
4503
4503
|
* Get the libraries for a site.
|
|
4504
4504
|
* @param id - (Optional) The drive id to target.
|
|
4505
4505
|
* @param siteId - (Optional) The site id to target, current by default.
|
|
4506
|
+
* @param siteUrl - (Optional) The site url to target, current by default.
|
|
4506
4507
|
* @param targetInfo - (Optional) The target information.
|
|
4507
4508
|
*/
|
|
4508
|
-
(props?: { driveId?: string, siteId?: string, targetInfo?: ITargetInfoProps }): IBaseExecution<driveCollection>;
|
|
4509
|
+
(props?: { driveId?: string, siteId?: string, siteUrl?: string, targetInfo?: ITargetInfoProps }): IBaseExecution<driveCollection>;
|
|
4509
4510
|
}
|
|
4510
4511
|
}
|
|
4511
4512
|
|
|
@@ -4539,7 +4540,7 @@ declare module 'gd-sprest/v2/sites' {
|
|
|
4539
4540
|
export interface Isites {
|
|
4540
4541
|
/**
|
|
4541
4542
|
* Creates an instance of the site library.
|
|
4542
|
-
* @param
|
|
4543
|
+
* @param siteId - (Optional) The site id to target, current by default.
|
|
4543
4544
|
* @param targetInfo - (Optional) The target information.
|
|
4544
4545
|
*/
|
|
4545
4546
|
(props?: { siteId?: string, targetInfo?: ITargetInfoProps }): siteMethods & sites;
|
|
@@ -4547,8 +4548,11 @@ declare module 'gd-sprest/v2/sites' {
|
|
|
4547
4548
|
/** Returns the current web. */
|
|
4548
4549
|
static getCurrentWeb(): IBaseExecution<sites> & siteMethods;
|
|
4549
4550
|
|
|
4550
|
-
/** Returns a
|
|
4551
|
-
static
|
|
4551
|
+
/** Returns a drive for a site. */
|
|
4552
|
+
static getDrive(props: { siteId?: string, siteUrl?: string, libName?: string }): IBaseExecution<list> & listMethods;
|
|
4553
|
+
|
|
4554
|
+
/** Returns a list for a site. */
|
|
4555
|
+
static getList(props: { siteId?: string, siteUrl?: string, listId?: string, listName?: string }): IBaseExecution<list> & listMethods;
|
|
4552
4556
|
}
|
|
4553
4557
|
}
|
|
4554
4558
|
|