@pnp/graph 2.10.0 → 2.13.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/LICENSE +25 -25
- package/attachments/conversations.d.ts +9 -9
- package/attachments/conversations.js +4 -4
- package/attachments/index.d.ts +2 -2
- package/attachments/index.js +2 -2
- package/attachments/types.d.ts +26 -26
- package/attachments/types.js +46 -46
- package/batch.d.ts +17 -17
- package/batch.js +176 -176
- package/calendars/funcs.d.ts +36 -36
- package/calendars/funcs.js +43 -43
- package/calendars/groups.d.ts +13 -13
- package/calendars/groups.js +5 -5
- package/calendars/index.d.ts +4 -4
- package/calendars/index.js +3 -3
- package/calendars/types.d.ts +52 -52
- package/calendars/types.js +98 -98
- package/calendars/users.d.ts +22 -22
- package/calendars/users.js +9 -9
- package/cloud-communications/index.d.ts +8 -8
- package/cloud-communications/index.js +14 -14
- package/cloud-communications/types.d.ts +21 -21
- package/cloud-communications/types.js +46 -46
- package/cloud-communications/users.d.ts +9 -9
- package/cloud-communications/users.js +4 -4
- package/contacts/index.d.ts +2 -2
- package/contacts/index.js +2 -2
- package/contacts/types.d.ts +75 -75
- package/contacts/types.js +145 -145
- package/contacts/users.d.ts +11 -11
- package/contacts/users.js +5 -5
- package/conversations/groups.d.ts +13 -13
- package/conversations/groups.js +6 -6
- package/conversations/index.d.ts +2 -2
- package/conversations/index.js +2 -2
- package/conversations/types.d.ts +103 -103
- package/conversations/types.js +173 -173
- package/decorators.d.ts +103 -103
- package/decorators.js +138 -138
- package/directory-objects/index.d.ts +7 -7
- package/directory-objects/index.js +13 -13
- package/directory-objects/types.d.ts +67 -67
- package/directory-objects/types.js +96 -96
- package/graphhttpclient.d.ts +13 -13
- package/graphhttpclient.js +95 -95
- package/graphlibconfig.d.ts +21 -21
- package/graphlibconfig.js +19 -19
- package/graphqueryable.d.ts +156 -156
- package/graphqueryable.js +247 -247
- package/groups/index.d.ts +7 -7
- package/groups/index.js +13 -13
- package/groups/types.d.ts +81 -81
- package/groups/types.js +137 -137
- package/index.d.ts +8 -8
- package/index.js +7 -7
- package/insights/index.d.ts +2 -2
- package/insights/index.js +2 -2
- package/insights/types.d.ts +76 -76
- package/insights/types.js +162 -162
- package/insights/users.d.ts +9 -9
- package/insights/users.js +4 -4
- package/invitations/index.d.ts +7 -7
- package/invitations/index.js +13 -13
- package/invitations/types.d.ts +25 -25
- package/invitations/types.js +44 -44
- package/members/groups.d.ts +11 -11
- package/members/groups.js +5 -5
- package/members/index.d.ts +2 -2
- package/members/index.js +2 -2
- package/members/types.d.ts +31 -31
- package/members/types.js +49 -49
- package/messages/index.d.ts +2 -2
- package/messages/index.js +2 -2
- package/messages/types.d.ts +43 -43
- package/messages/types.js +77 -77
- package/messages/users.d.ts +15 -15
- package/messages/users.js +10 -10
- package/onedrive/index.d.ts +2 -2
- package/onedrive/index.js +2 -2
- package/onedrive/types.d.ts +95 -95
- package/onedrive/types.js +241 -241
- package/onedrive/users.d.ts +11 -11
- package/onedrive/users.js +5 -5
- package/onenote/index.d.ts +2 -2
- package/onenote/index.js +2 -2
- package/onenote/types.d.ts +76 -76
- package/onenote/types.js +149 -149
- package/onenote/users.d.ts +9 -9
- package/onenote/users.js +4 -4
- package/operations.d.ts +8 -8
- package/operations.js +41 -41
- package/outlook/index.d.ts +2 -2
- package/outlook/index.js +2 -2
- package/outlook/types.d.ts +40 -40
- package/outlook/types.js +76 -76
- package/outlook/users.d.ts +9 -9
- package/outlook/users.js +4 -4
- package/package.json +5 -5
- package/photos/groups.d.ts +9 -9
- package/photos/groups.js +4 -4
- package/photos/index.d.ts +3 -3
- package/photos/index.js +3 -3
- package/photos/types.d.ts +21 -21
- package/photos/types.js +37 -37
- package/photos/users.d.ts +9 -9
- package/photos/users.js +4 -4
- package/planner/groups.d.ts +9 -9
- package/planner/groups.js +4 -4
- package/planner/index.d.ts +9 -9
- package/planner/index.js +15 -15
- package/planner/types.d.ts +117 -117
- package/planner/types.js +291 -291
- package/planner/users.d.ts +9 -9
- package/planner/users.js +4 -4
- package/presets/all.d.ts +38 -38
- package/presets/all.js +38 -38
- package/readme.md +21 -21
- package/rest.d.ts +30 -30
- package/rest.js +57 -57
- package/search/index.d.ts +7 -7
- package/search/index.js +18 -18
- package/search/types.d.ts +16 -16
- package/search/types.js +23 -23
- package/sites/group.d.ts +9 -9
- package/sites/group.js +4 -4
- package/sites/index.d.ts +2 -2
- package/sites/index.js +2 -2
- package/sites/types.d.ts +23 -23
- package/sites/types.js +47 -47
- package/subscriptions/index.d.ts +7 -7
- package/subscriptions/index.js +13 -13
- package/subscriptions/types.d.ts +37 -37
- package/subscriptions/types.js +72 -72
- package/teams/index.d.ts +19 -19
- package/teams/index.js +35 -35
- package/teams/types.d.ts +112 -111
- package/teams/types.d.ts.map +1 -1
- package/teams/types.js +261 -254
- package/teams/types.js.map +1 -1
- package/teams/users.d.ts +9 -9
- package/teams/users.js +4 -4
- package/types.d.ts +9 -9
- package/types.js +19 -19
- package/users/index.d.ts +8 -8
- package/users/index.js +23 -23
- package/users/types.d.ts +35 -35
- package/users/types.js +82 -82
- package/utils/toabsoluteurl.d.ts +7 -7
- package/utils/toabsoluteurl.js +48 -48
- package/utils/type.d.ts +3 -3
- package/utils/type.js +3 -3
|
@@ -1,97 +1,97 @@
|
|
|
1
|
-
import { __decorate, __extends } from "tslib";
|
|
2
|
-
import { _GraphQueryableCollection, _GraphQueryableInstance, graphInvokableFactory } from "../graphqueryable.js";
|
|
3
|
-
import { defaultPath, getById, deleteable } from "../decorators.js";
|
|
4
|
-
import { body } from "@pnp/odata";
|
|
5
|
-
import { graphPost } from "../operations.js";
|
|
6
|
-
/**
|
|
7
|
-
* Represents a Directory Object entity
|
|
8
|
-
*/
|
|
9
|
-
var _DirectoryObject = /** @class */ (function (_super) {
|
|
10
|
-
__extends(_DirectoryObject, _super);
|
|
11
|
-
function _DirectoryObject() {
|
|
12
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Returns all the groups and directory roles that the specified Directory Object is a member of. The check is transitive
|
|
16
|
-
*
|
|
17
|
-
* @param securityEnabledOnly
|
|
18
|
-
*/
|
|
19
|
-
_DirectoryObject.prototype.getMemberObjects = function (securityEnabledOnly) {
|
|
20
|
-
if (securityEnabledOnly === void 0) { securityEnabledOnly = false; }
|
|
21
|
-
return graphPost(this.clone(DirectoryObject, "getMemberObjects"), body({ securityEnabledOnly: securityEnabledOnly }));
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* Returns all the groups that the specified Directory Object is a member of. The check is transitive
|
|
25
|
-
*
|
|
26
|
-
* @param securityEnabledOnly
|
|
27
|
-
*/
|
|
28
|
-
_DirectoryObject.prototype.getMemberGroups = function (securityEnabledOnly) {
|
|
29
|
-
if (securityEnabledOnly === void 0) { securityEnabledOnly = false; }
|
|
30
|
-
return graphPost(this.clone(DirectoryObject, "getMemberGroups"), body({ securityEnabledOnly: securityEnabledOnly }));
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* Check for membership in a specified list of groups, and returns from that list those groups of which the specified user, group, or directory object is a member.
|
|
34
|
-
* This function is transitive.
|
|
35
|
-
* @param groupIds A collection that contains the object IDs of the groups in which to check membership. Up to 20 groups may be specified.
|
|
36
|
-
*/
|
|
37
|
-
_DirectoryObject.prototype.checkMemberGroups = function (groupIds) {
|
|
38
|
-
return graphPost(this.clone(DirectoryObject, "checkMemberGroups"), body({ groupIds: groupIds }));
|
|
39
|
-
};
|
|
40
|
-
_DirectoryObject = __decorate([
|
|
41
|
-
deleteable()
|
|
42
|
-
], _DirectoryObject);
|
|
43
|
-
return _DirectoryObject;
|
|
44
|
-
}(_GraphQueryableInstance));
|
|
45
|
-
export { _DirectoryObject };
|
|
46
|
-
export var DirectoryObject = graphInvokableFactory(_DirectoryObject);
|
|
47
|
-
/**
|
|
48
|
-
* Describes a collection of Directory Objects
|
|
49
|
-
*
|
|
50
|
-
*/
|
|
51
|
-
var _DirectoryObjects = /** @class */ (function (_super) {
|
|
52
|
-
__extends(_DirectoryObjects, _super);
|
|
53
|
-
function _DirectoryObjects() {
|
|
54
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Returns the directory objects specified in a list of ids. NOTE: The directory objects returned are the full objects containing all their properties.
|
|
58
|
-
* The $select query option is not available for this operation.
|
|
59
|
-
*
|
|
60
|
-
* @param ids A collection of ids for which to return objects. You can specify up to 1000 ids.
|
|
61
|
-
* @param type A collection of resource types that specifies the set of resource collections to search. Default is directoryObject.
|
|
62
|
-
*/
|
|
63
|
-
_DirectoryObjects.prototype.getByIds = function (ids, type) {
|
|
64
|
-
if (type === void 0) { type = DirectoryObjectTypes.directoryObject; }
|
|
65
|
-
return graphPost(this.clone(DirectoryObjects, "getByIds"), body({ ids: ids, type: type }));
|
|
66
|
-
};
|
|
67
|
-
_DirectoryObjects = __decorate([
|
|
68
|
-
defaultPath("directoryObjects"),
|
|
69
|
-
getById(DirectoryObject)
|
|
70
|
-
], _DirectoryObjects);
|
|
71
|
-
return _DirectoryObjects;
|
|
72
|
-
}(_GraphQueryableCollection));
|
|
73
|
-
export { _DirectoryObjects };
|
|
74
|
-
export var DirectoryObjects = graphInvokableFactory(_DirectoryObjects);
|
|
75
|
-
/**
|
|
76
|
-
* DirectoryObjectTypes
|
|
77
|
-
*/
|
|
78
|
-
export var DirectoryObjectTypes;
|
|
79
|
-
(function (DirectoryObjectTypes) {
|
|
80
|
-
/**
|
|
81
|
-
* Directory Objects
|
|
82
|
-
*/
|
|
83
|
-
DirectoryObjectTypes[DirectoryObjectTypes["directoryObject"] = 0] = "directoryObject";
|
|
84
|
-
/**
|
|
85
|
-
* User
|
|
86
|
-
*/
|
|
87
|
-
DirectoryObjectTypes[DirectoryObjectTypes["user"] = 1] = "user";
|
|
88
|
-
/**
|
|
89
|
-
* Group
|
|
90
|
-
*/
|
|
91
|
-
DirectoryObjectTypes[DirectoryObjectTypes["group"] = 2] = "group";
|
|
92
|
-
/**
|
|
93
|
-
* Device
|
|
94
|
-
*/
|
|
95
|
-
DirectoryObjectTypes[DirectoryObjectTypes["device"] = 3] = "device";
|
|
96
|
-
})(DirectoryObjectTypes || (DirectoryObjectTypes = {}));
|
|
1
|
+
import { __decorate, __extends } from "tslib";
|
|
2
|
+
import { _GraphQueryableCollection, _GraphQueryableInstance, graphInvokableFactory } from "../graphqueryable.js";
|
|
3
|
+
import { defaultPath, getById, deleteable } from "../decorators.js";
|
|
4
|
+
import { body } from "@pnp/odata";
|
|
5
|
+
import { graphPost } from "../operations.js";
|
|
6
|
+
/**
|
|
7
|
+
* Represents a Directory Object entity
|
|
8
|
+
*/
|
|
9
|
+
var _DirectoryObject = /** @class */ (function (_super) {
|
|
10
|
+
__extends(_DirectoryObject, _super);
|
|
11
|
+
function _DirectoryObject() {
|
|
12
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Returns all the groups and directory roles that the specified Directory Object is a member of. The check is transitive
|
|
16
|
+
*
|
|
17
|
+
* @param securityEnabledOnly
|
|
18
|
+
*/
|
|
19
|
+
_DirectoryObject.prototype.getMemberObjects = function (securityEnabledOnly) {
|
|
20
|
+
if (securityEnabledOnly === void 0) { securityEnabledOnly = false; }
|
|
21
|
+
return graphPost(this.clone(DirectoryObject, "getMemberObjects"), body({ securityEnabledOnly: securityEnabledOnly }));
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Returns all the groups that the specified Directory Object is a member of. The check is transitive
|
|
25
|
+
*
|
|
26
|
+
* @param securityEnabledOnly
|
|
27
|
+
*/
|
|
28
|
+
_DirectoryObject.prototype.getMemberGroups = function (securityEnabledOnly) {
|
|
29
|
+
if (securityEnabledOnly === void 0) { securityEnabledOnly = false; }
|
|
30
|
+
return graphPost(this.clone(DirectoryObject, "getMemberGroups"), body({ securityEnabledOnly: securityEnabledOnly }));
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Check for membership in a specified list of groups, and returns from that list those groups of which the specified user, group, or directory object is a member.
|
|
34
|
+
* This function is transitive.
|
|
35
|
+
* @param groupIds A collection that contains the object IDs of the groups in which to check membership. Up to 20 groups may be specified.
|
|
36
|
+
*/
|
|
37
|
+
_DirectoryObject.prototype.checkMemberGroups = function (groupIds) {
|
|
38
|
+
return graphPost(this.clone(DirectoryObject, "checkMemberGroups"), body({ groupIds: groupIds }));
|
|
39
|
+
};
|
|
40
|
+
_DirectoryObject = __decorate([
|
|
41
|
+
deleteable()
|
|
42
|
+
], _DirectoryObject);
|
|
43
|
+
return _DirectoryObject;
|
|
44
|
+
}(_GraphQueryableInstance));
|
|
45
|
+
export { _DirectoryObject };
|
|
46
|
+
export var DirectoryObject = graphInvokableFactory(_DirectoryObject);
|
|
47
|
+
/**
|
|
48
|
+
* Describes a collection of Directory Objects
|
|
49
|
+
*
|
|
50
|
+
*/
|
|
51
|
+
var _DirectoryObjects = /** @class */ (function (_super) {
|
|
52
|
+
__extends(_DirectoryObjects, _super);
|
|
53
|
+
function _DirectoryObjects() {
|
|
54
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Returns the directory objects specified in a list of ids. NOTE: The directory objects returned are the full objects containing all their properties.
|
|
58
|
+
* The $select query option is not available for this operation.
|
|
59
|
+
*
|
|
60
|
+
* @param ids A collection of ids for which to return objects. You can specify up to 1000 ids.
|
|
61
|
+
* @param type A collection of resource types that specifies the set of resource collections to search. Default is directoryObject.
|
|
62
|
+
*/
|
|
63
|
+
_DirectoryObjects.prototype.getByIds = function (ids, type) {
|
|
64
|
+
if (type === void 0) { type = DirectoryObjectTypes.directoryObject; }
|
|
65
|
+
return graphPost(this.clone(DirectoryObjects, "getByIds"), body({ ids: ids, type: type }));
|
|
66
|
+
};
|
|
67
|
+
_DirectoryObjects = __decorate([
|
|
68
|
+
defaultPath("directoryObjects"),
|
|
69
|
+
getById(DirectoryObject)
|
|
70
|
+
], _DirectoryObjects);
|
|
71
|
+
return _DirectoryObjects;
|
|
72
|
+
}(_GraphQueryableCollection));
|
|
73
|
+
export { _DirectoryObjects };
|
|
74
|
+
export var DirectoryObjects = graphInvokableFactory(_DirectoryObjects);
|
|
75
|
+
/**
|
|
76
|
+
* DirectoryObjectTypes
|
|
77
|
+
*/
|
|
78
|
+
export var DirectoryObjectTypes;
|
|
79
|
+
(function (DirectoryObjectTypes) {
|
|
80
|
+
/**
|
|
81
|
+
* Directory Objects
|
|
82
|
+
*/
|
|
83
|
+
DirectoryObjectTypes[DirectoryObjectTypes["directoryObject"] = 0] = "directoryObject";
|
|
84
|
+
/**
|
|
85
|
+
* User
|
|
86
|
+
*/
|
|
87
|
+
DirectoryObjectTypes[DirectoryObjectTypes["user"] = 1] = "user";
|
|
88
|
+
/**
|
|
89
|
+
* Group
|
|
90
|
+
*/
|
|
91
|
+
DirectoryObjectTypes[DirectoryObjectTypes["group"] = 2] = "group";
|
|
92
|
+
/**
|
|
93
|
+
* Device
|
|
94
|
+
*/
|
|
95
|
+
DirectoryObjectTypes[DirectoryObjectTypes["device"] = 3] = "device";
|
|
96
|
+
})(DirectoryObjectTypes || (DirectoryObjectTypes = {}));
|
|
97
97
|
//# sourceMappingURL=types.js.map
|
package/graphhttpclient.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { IRequestClient, IFetchOptions, IHttpClientImpl, Runtime } from "@pnp/common";
|
|
2
|
-
export declare class GraphHttpClient implements IRequestClient {
|
|
3
|
-
protected _runtime: Runtime;
|
|
4
|
-
private _impl;
|
|
5
|
-
constructor(runtime?: Runtime);
|
|
6
|
-
constructor(runtime?: Runtime, impl?: IHttpClientImpl);
|
|
7
|
-
fetch(url: string, options?: IFetchOptions): Promise<Response>;
|
|
8
|
-
fetchRaw(url: string, options?: IFetchOptions): Promise<Response>;
|
|
9
|
-
get(url: string, options?: IFetchOptions): Promise<Response>;
|
|
10
|
-
post(url: string, options?: IFetchOptions): Promise<Response>;
|
|
11
|
-
patch(url: string, options?: IFetchOptions): Promise<Response>;
|
|
12
|
-
delete(url: string, options?: IFetchOptions): Promise<Response>;
|
|
13
|
-
}
|
|
1
|
+
import { IRequestClient, IFetchOptions, IHttpClientImpl, Runtime } from "@pnp/common";
|
|
2
|
+
export declare class GraphHttpClient implements IRequestClient {
|
|
3
|
+
protected _runtime: Runtime;
|
|
4
|
+
private _impl;
|
|
5
|
+
constructor(runtime?: Runtime);
|
|
6
|
+
constructor(runtime?: Runtime, impl?: IHttpClientImpl);
|
|
7
|
+
fetch(url: string, options?: IFetchOptions): Promise<Response>;
|
|
8
|
+
fetchRaw(url: string, options?: IFetchOptions): Promise<Response>;
|
|
9
|
+
get(url: string, options?: IFetchOptions): Promise<Response>;
|
|
10
|
+
post(url: string, options?: IFetchOptions): Promise<Response>;
|
|
11
|
+
patch(url: string, options?: IFetchOptions): Promise<Response>;
|
|
12
|
+
delete(url: string, options?: IFetchOptions): Promise<Response>;
|
|
13
|
+
}
|
|
14
14
|
//# sourceMappingURL=graphhttpclient.d.ts.map
|
package/graphhttpclient.js
CHANGED
|
@@ -1,96 +1,96 @@
|
|
|
1
|
-
import { assign, mergeHeaders, getCtxCallback, DefaultRuntime, Runtime, objectDefinedNotNull, } from "@pnp/common";
|
|
2
|
-
var GraphHttpClient = /** @class */ (function () {
|
|
3
|
-
function GraphHttpClient() {
|
|
4
|
-
// constructor(...args: [runtime: Runtime] | [impl: IHttpClientImpl, runtime?: Runtime]) {
|
|
5
|
-
var args = [];
|
|
6
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
7
|
-
args[_i] = arguments[_i];
|
|
8
|
-
}
|
|
9
|
-
this._runtime = args.length > 0 && args[0] instanceof Runtime ? args[0] : DefaultRuntime;
|
|
10
|
-
this._impl = args.length > 1 && objectDefinedNotNull(args[1]) ?
|
|
11
|
-
args[1] : this._runtime.get("graph").fetchClientFactory() || null;
|
|
12
|
-
if (this._impl === null) {
|
|
13
|
-
throw Error("Could not generate fetchClientFactory in SPHttpClient.");
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
GraphHttpClient.prototype.fetch = function (url, options) {
|
|
17
|
-
var _a;
|
|
18
|
-
if (options === void 0) { options = {}; }
|
|
19
|
-
var headers = new Headers();
|
|
20
|
-
// first we add the global headers so they can be overwritten by any passed in locally to this call
|
|
21
|
-
mergeHeaders(headers, (_a = this._runtime.get("graph")) === null || _a === void 0 ? void 0 : _a.headers);
|
|
22
|
-
// second we add the local options so we can overwrite the globals
|
|
23
|
-
mergeHeaders(headers, options.headers);
|
|
24
|
-
if (!headers.has("Content-Type")) {
|
|
25
|
-
headers.append("Content-Type", "application/json");
|
|
26
|
-
}
|
|
27
|
-
if (!headers.has("SdkVersion")) {
|
|
28
|
-
// this marks the requests for understanding by the service
|
|
29
|
-
headers.append("SdkVersion", "PnPCoreJS/2.
|
|
30
|
-
}
|
|
31
|
-
var opts = assign(options, { headers: headers });
|
|
32
|
-
return this.fetchRaw(url, opts);
|
|
33
|
-
};
|
|
34
|
-
GraphHttpClient.prototype.fetchRaw = function (url, options) {
|
|
35
|
-
var _this = this;
|
|
36
|
-
if (options === void 0) { options = {}; }
|
|
37
|
-
// here we need to normalize the headers
|
|
38
|
-
var rawHeaders = new Headers();
|
|
39
|
-
mergeHeaders(rawHeaders, options.headers);
|
|
40
|
-
options = assign(options, { headers: rawHeaders });
|
|
41
|
-
var retry = function (ctx) {
|
|
42
|
-
_this._impl.fetch(url, options).then(function (response) { return ctx.resolve(response); }).catch(function (response) {
|
|
43
|
-
// Check if request was throttled - http status code 429
|
|
44
|
-
// Check if request failed due to server unavailable - http status code 503
|
|
45
|
-
// Check if request failed due to gateway timeout - http status code 504
|
|
46
|
-
if (response.status !== 429 && response.status !== 503 && response.status !== 504) {
|
|
47
|
-
ctx.reject(response);
|
|
48
|
-
}
|
|
49
|
-
// grab our current delay
|
|
50
|
-
var delay = ctx.delay;
|
|
51
|
-
// Increment our counters.
|
|
52
|
-
ctx.delay *= 2;
|
|
53
|
-
ctx.attempts++;
|
|
54
|
-
// If we have exceeded the retry count, reject.
|
|
55
|
-
if (ctx.retryCount <= ctx.attempts) {
|
|
56
|
-
ctx.reject(response);
|
|
57
|
-
}
|
|
58
|
-
// Set our retry timeout for {delay} milliseconds.
|
|
59
|
-
setTimeout(getCtxCallback(_this, retry, ctx), delay);
|
|
60
|
-
});
|
|
61
|
-
};
|
|
62
|
-
return new Promise(function (resolve, reject) {
|
|
63
|
-
var retryContext = {
|
|
64
|
-
attempts: 0,
|
|
65
|
-
delay: 100,
|
|
66
|
-
reject: reject,
|
|
67
|
-
resolve: resolve,
|
|
68
|
-
retryCount: 7,
|
|
69
|
-
};
|
|
70
|
-
retry.call(_this, retryContext);
|
|
71
|
-
});
|
|
72
|
-
};
|
|
73
|
-
GraphHttpClient.prototype.get = function (url, options) {
|
|
74
|
-
if (options === void 0) { options = {}; }
|
|
75
|
-
var opts = assign(options, { method: "GET" });
|
|
76
|
-
return this.fetch(url, opts);
|
|
77
|
-
};
|
|
78
|
-
GraphHttpClient.prototype.post = function (url, options) {
|
|
79
|
-
if (options === void 0) { options = {}; }
|
|
80
|
-
var opts = assign(options, { method: "POST" });
|
|
81
|
-
return this.fetch(url, opts);
|
|
82
|
-
};
|
|
83
|
-
GraphHttpClient.prototype.patch = function (url, options) {
|
|
84
|
-
if (options === void 0) { options = {}; }
|
|
85
|
-
var opts = assign(options, { method: "PATCH" });
|
|
86
|
-
return this.fetch(url, opts);
|
|
87
|
-
};
|
|
88
|
-
GraphHttpClient.prototype.delete = function (url, options) {
|
|
89
|
-
if (options === void 0) { options = {}; }
|
|
90
|
-
var opts = assign(options, { method: "DELETE" });
|
|
91
|
-
return this.fetch(url, opts);
|
|
92
|
-
};
|
|
93
|
-
return GraphHttpClient;
|
|
94
|
-
}());
|
|
95
|
-
export { GraphHttpClient };
|
|
1
|
+
import { assign, mergeHeaders, getCtxCallback, DefaultRuntime, Runtime, objectDefinedNotNull, } from "@pnp/common";
|
|
2
|
+
var GraphHttpClient = /** @class */ (function () {
|
|
3
|
+
function GraphHttpClient() {
|
|
4
|
+
// constructor(...args: [runtime: Runtime] | [impl: IHttpClientImpl, runtime?: Runtime]) {
|
|
5
|
+
var args = [];
|
|
6
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
7
|
+
args[_i] = arguments[_i];
|
|
8
|
+
}
|
|
9
|
+
this._runtime = args.length > 0 && args[0] instanceof Runtime ? args[0] : DefaultRuntime;
|
|
10
|
+
this._impl = args.length > 1 && objectDefinedNotNull(args[1]) ?
|
|
11
|
+
args[1] : this._runtime.get("graph").fetchClientFactory() || null;
|
|
12
|
+
if (this._impl === null) {
|
|
13
|
+
throw Error("Could not generate fetchClientFactory in SPHttpClient.");
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
GraphHttpClient.prototype.fetch = function (url, options) {
|
|
17
|
+
var _a;
|
|
18
|
+
if (options === void 0) { options = {}; }
|
|
19
|
+
var headers = new Headers();
|
|
20
|
+
// first we add the global headers so they can be overwritten by any passed in locally to this call
|
|
21
|
+
mergeHeaders(headers, (_a = this._runtime.get("graph")) === null || _a === void 0 ? void 0 : _a.headers);
|
|
22
|
+
// second we add the local options so we can overwrite the globals
|
|
23
|
+
mergeHeaders(headers, options.headers);
|
|
24
|
+
if (!headers.has("Content-Type")) {
|
|
25
|
+
headers.append("Content-Type", "application/json");
|
|
26
|
+
}
|
|
27
|
+
if (!headers.has("SdkVersion")) {
|
|
28
|
+
// this marks the requests for understanding by the service
|
|
29
|
+
headers.append("SdkVersion", "PnPCoreJS/2.13.0");
|
|
30
|
+
}
|
|
31
|
+
var opts = assign(options, { headers: headers });
|
|
32
|
+
return this.fetchRaw(url, opts);
|
|
33
|
+
};
|
|
34
|
+
GraphHttpClient.prototype.fetchRaw = function (url, options) {
|
|
35
|
+
var _this = this;
|
|
36
|
+
if (options === void 0) { options = {}; }
|
|
37
|
+
// here we need to normalize the headers
|
|
38
|
+
var rawHeaders = new Headers();
|
|
39
|
+
mergeHeaders(rawHeaders, options.headers);
|
|
40
|
+
options = assign(options, { headers: rawHeaders });
|
|
41
|
+
var retry = function (ctx) {
|
|
42
|
+
_this._impl.fetch(url, options).then(function (response) { return ctx.resolve(response); }).catch(function (response) {
|
|
43
|
+
// Check if request was throttled - http status code 429
|
|
44
|
+
// Check if request failed due to server unavailable - http status code 503
|
|
45
|
+
// Check if request failed due to gateway timeout - http status code 504
|
|
46
|
+
if (response.status !== 429 && response.status !== 503 && response.status !== 504) {
|
|
47
|
+
ctx.reject(response);
|
|
48
|
+
}
|
|
49
|
+
// grab our current delay
|
|
50
|
+
var delay = ctx.delay;
|
|
51
|
+
// Increment our counters.
|
|
52
|
+
ctx.delay *= 2;
|
|
53
|
+
ctx.attempts++;
|
|
54
|
+
// If we have exceeded the retry count, reject.
|
|
55
|
+
if (ctx.retryCount <= ctx.attempts) {
|
|
56
|
+
ctx.reject(response);
|
|
57
|
+
}
|
|
58
|
+
// Set our retry timeout for {delay} milliseconds.
|
|
59
|
+
setTimeout(getCtxCallback(_this, retry, ctx), delay);
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
return new Promise(function (resolve, reject) {
|
|
63
|
+
var retryContext = {
|
|
64
|
+
attempts: 0,
|
|
65
|
+
delay: 100,
|
|
66
|
+
reject: reject,
|
|
67
|
+
resolve: resolve,
|
|
68
|
+
retryCount: 7,
|
|
69
|
+
};
|
|
70
|
+
retry.call(_this, retryContext);
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
GraphHttpClient.prototype.get = function (url, options) {
|
|
74
|
+
if (options === void 0) { options = {}; }
|
|
75
|
+
var opts = assign(options, { method: "GET" });
|
|
76
|
+
return this.fetch(url, opts);
|
|
77
|
+
};
|
|
78
|
+
GraphHttpClient.prototype.post = function (url, options) {
|
|
79
|
+
if (options === void 0) { options = {}; }
|
|
80
|
+
var opts = assign(options, { method: "POST" });
|
|
81
|
+
return this.fetch(url, opts);
|
|
82
|
+
};
|
|
83
|
+
GraphHttpClient.prototype.patch = function (url, options) {
|
|
84
|
+
if (options === void 0) { options = {}; }
|
|
85
|
+
var opts = assign(options, { method: "PATCH" });
|
|
86
|
+
return this.fetch(url, opts);
|
|
87
|
+
};
|
|
88
|
+
GraphHttpClient.prototype.delete = function (url, options) {
|
|
89
|
+
if (options === void 0) { options = {}; }
|
|
90
|
+
var opts = assign(options, { method: "DELETE" });
|
|
91
|
+
return this.fetch(url, opts);
|
|
92
|
+
};
|
|
93
|
+
return GraphHttpClient;
|
|
94
|
+
}());
|
|
95
|
+
export { GraphHttpClient };
|
|
96
96
|
//# sourceMappingURL=graphhttpclient.js.map
|
package/graphlibconfig.d.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { ILibraryConfiguration, ITypedHash, IHttpClientImpl, Runtime } from "@pnp/common";
|
|
2
|
-
export interface IGraphConfigurationPart {
|
|
3
|
-
graph?: IGraphConfigurationProps;
|
|
4
|
-
}
|
|
5
|
-
export interface IGraphConfigurationProps {
|
|
6
|
-
/**
|
|
7
|
-
* The base url used for all requests (default: none)
|
|
8
|
-
*/
|
|
9
|
-
baseUrl?: string;
|
|
10
|
-
/**
|
|
11
|
-
* Any headers to apply to all requests
|
|
12
|
-
*/
|
|
13
|
-
headers?: ITypedHash<string>;
|
|
14
|
-
/**
|
|
15
|
-
* Defines a factory method used to create fetch clients
|
|
16
|
-
*/
|
|
17
|
-
fetchClientFactory?: () => IHttpClientImpl;
|
|
18
|
-
}
|
|
19
|
-
export interface IGraphConfiguration extends ILibraryConfiguration, IGraphConfigurationPart {
|
|
20
|
-
}
|
|
21
|
-
export declare function setup(config: IGraphConfiguration, runtime?: Runtime): void;
|
|
1
|
+
import { ILibraryConfiguration, ITypedHash, IHttpClientImpl, Runtime } from "@pnp/common";
|
|
2
|
+
export interface IGraphConfigurationPart {
|
|
3
|
+
graph?: IGraphConfigurationProps;
|
|
4
|
+
}
|
|
5
|
+
export interface IGraphConfigurationProps {
|
|
6
|
+
/**
|
|
7
|
+
* The base url used for all requests (default: none)
|
|
8
|
+
*/
|
|
9
|
+
baseUrl?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Any headers to apply to all requests
|
|
12
|
+
*/
|
|
13
|
+
headers?: ITypedHash<string>;
|
|
14
|
+
/**
|
|
15
|
+
* Defines a factory method used to create fetch clients
|
|
16
|
+
*/
|
|
17
|
+
fetchClientFactory?: () => IHttpClientImpl;
|
|
18
|
+
}
|
|
19
|
+
export interface IGraphConfiguration extends ILibraryConfiguration, IGraphConfigurationPart {
|
|
20
|
+
}
|
|
21
|
+
export declare function setup(config: IGraphConfiguration, runtime?: Runtime): void;
|
|
22
22
|
//# sourceMappingURL=graphlibconfig.d.ts.map
|
package/graphlibconfig.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { SPFxAdalClient, DefaultRuntime, onRuntimeCreate, objectDefinedNotNull } from "@pnp/common";
|
|
2
|
-
onRuntimeCreate(function (runtime) {
|
|
3
|
-
var existing = runtime.get("graph");
|
|
4
|
-
var graphPart = Object.assign({}, {
|
|
5
|
-
fetchClientFactory: function () {
|
|
6
|
-
// we keep a ref to the runtime within which we are assigned
|
|
7
|
-
var context = runtime.get("spfxContext");
|
|
8
|
-
if (objectDefinedNotNull(context)) {
|
|
9
|
-
return new SPFxAdalClient(context);
|
|
10
|
-
}
|
|
11
|
-
throw Error("There is no Graph Client available, either set one using configuration or provide a valid SPFx Context.");
|
|
12
|
-
},
|
|
13
|
-
}, existing);
|
|
14
|
-
runtime.assign({ graph: graphPart });
|
|
15
|
-
});
|
|
16
|
-
export function setup(config, runtime) {
|
|
17
|
-
if (runtime === void 0) { runtime = DefaultRuntime; }
|
|
18
|
-
runtime.assign(config);
|
|
19
|
-
}
|
|
1
|
+
import { SPFxAdalClient, DefaultRuntime, onRuntimeCreate, objectDefinedNotNull } from "@pnp/common";
|
|
2
|
+
onRuntimeCreate(function (runtime) {
|
|
3
|
+
var existing = runtime.get("graph");
|
|
4
|
+
var graphPart = Object.assign({}, {
|
|
5
|
+
fetchClientFactory: function () {
|
|
6
|
+
// we keep a ref to the runtime within which we are assigned
|
|
7
|
+
var context = runtime.get("spfxContext");
|
|
8
|
+
if (objectDefinedNotNull(context)) {
|
|
9
|
+
return new SPFxAdalClient(context);
|
|
10
|
+
}
|
|
11
|
+
throw Error("There is no Graph Client available, either set one using configuration or provide a valid SPFx Context.");
|
|
12
|
+
},
|
|
13
|
+
}, existing);
|
|
14
|
+
runtime.assign({ graph: graphPart });
|
|
15
|
+
});
|
|
16
|
+
export function setup(config, runtime) {
|
|
17
|
+
if (runtime === void 0) { runtime = DefaultRuntime; }
|
|
18
|
+
runtime.assign(config);
|
|
19
|
+
}
|
|
20
20
|
//# sourceMappingURL=graphlibconfig.js.map
|