@microsoft/sp-http-msgraph 1.23.2 → 1.24.0-beta.3
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/dist/aec2bbfd-a968-4d5b-a279-12e570f378e6.manifest.json +132 -142
- package/dist/chunk.sp-http-msgraphclient_none_d27ed442ec7d722ce010.js +2 -0
- package/dist/chunk.sp-http-msgraphclientv3_none_9281ffc867d9cec318da.js +2 -0
- package/dist/sp-http-msgraph_default_e84339d413394b88cfcc.js +2 -0
- package/dist/sp-http-msgraph_en-us_87ca82c598208572f1dc.js +2 -0
- package/dist/sp-http-msgraph_qps-ploc_f3b793e56d4fd64233b4.js +2 -0
- package/dist/sp-http-msgraph_qps-ploca_f9ba03ad591651a22c99.js +2 -0
- package/dist/tsdoc-metadata.json +1 -1
- package/lib-commonjs/KillSwitches.js +16 -0
- package/lib-commonjs/MSGraphAuthenticationProvider.js +39 -33
- package/lib-commonjs/MSGraphClient.js +71 -82
- package/lib-commonjs/MSGraphClientFactory.js +73 -79
- package/lib-commonjs/MSGraphClientV3.js +135 -156
- package/lib-commonjs/common/Killswitches.js +26 -16
- package/lib-commonjs/index.js +23 -12
- package/lib-dts/KillSwitches.d.ts +2 -0
- package/{lib → lib-dts}/SPHttpMsGraphStrings.resx.d.ts +2 -1
- package/lib-esm/KillSwitches.js +6 -0
- package/lib-esm/MSGraphAuthenticationProvider.js +49 -0
- package/lib-esm/MSGraphClient.js +97 -0
- package/lib-esm/MSGraphClientFactory.js +94 -0
- package/lib-esm/MSGraphClientV3.js +190 -0
- package/{lib → lib-esm}/common/Killswitches.js +5 -10
- package/{lib → lib-esm}/index.js +3 -3
- package/package.json +41 -10
- package/dist/chunk.sp-http-msgraphclient_none_99a41fce9bf3925a21e2.js +0 -2
- package/dist/chunk.sp-http-msgraphclientv3_none_c34e76d04711b268a3cd.js +0 -2
- package/dist/sp-http-msgraph_default_6e69c31eaaed44b5aab3.js +0 -1
- package/dist/sp-http-msgraph_en-us_26c6c90f8da57ad234d5.js +0 -1
- package/dist/sp-http-msgraph_qps-ploc_db5eb720e90b9545bca7.js +0 -1
- package/dist/sp-http-msgraph_qps-ploca_cb2655427d0c64681f92.js +0 -1
- package/lib/MSGraphAuthenticationProvider.d.ts.map +0 -1
- package/lib/MSGraphAuthenticationProvider.js +0 -50
- package/lib/MSGraphClient.d.ts.map +0 -1
- package/lib/MSGraphClient.js +0 -104
- package/lib/MSGraphClientFactory.d.ts.map +0 -1
- package/lib/MSGraphClientFactory.js +0 -106
- package/lib/MSGraphClientV3.d.ts.map +0 -1
- package/lib/MSGraphClientV3.js +0 -206
- package/lib/common/Killswitches.d.ts.map +0 -1
- package/lib/index.d.ts.map +0 -1
- /package/{lib → lib-dts}/MSGraphAuthenticationProvider.d.ts +0 -0
- /package/{lib → lib-dts}/MSGraphClient.d.ts +0 -0
- /package/{lib → lib-dts}/MSGraphClientFactory.d.ts +0 -0
- /package/{lib → lib-dts}/MSGraphClientV3.d.ts +0 -0
- /package/{lib → lib-dts}/common/Killswitches.d.ts +0 -0
- /package/{lib → lib-dts}/index.d.ts +0 -0
- /package/{lib → lib-esm}/SPHttpMsGraphStrings.resx.json +0 -0
- /package/{lib → lib-esm}/sp-http-msgraph.manifest.json +0 -0
|
@@ -1,82 +1,60 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* MSGraphClient is used to perform REST calls against Microsoft Graph.
|
|
10
|
-
*
|
|
11
|
-
* @remarks The Microsoft Graph JavaScript client library is a lightweight wrapper around the
|
|
12
|
-
* Microsoft Graph API. This class allows developers to start making REST calls to MSGraph without
|
|
13
|
-
* needing to initialize the the MSGraph client library. If a custom configuration is desired,
|
|
14
|
-
* the MSGraphClient api function needs to be provided with that custom configuration for
|
|
15
|
-
* every request.
|
|
16
|
-
*
|
|
17
|
-
* For more information: {@link https://github.com/microsoftgraph/msgraph-sdk-javascript}
|
|
18
|
-
*
|
|
19
|
-
* @public
|
|
20
|
-
*/
|
|
21
|
-
var MSGraphClient = /** @class */ (function () {
|
|
22
|
-
/**
|
|
23
|
-
* @param serviceScope - Provides services for the MSGraphClient to consume.
|
|
24
|
-
*
|
|
25
|
-
* @internal
|
|
26
|
-
*/
|
|
27
|
-
function MSGraphClient(serviceScope) {
|
|
28
|
-
var _this = this;
|
|
29
|
-
serviceScope.whenFinished(function () {
|
|
30
|
-
MSGraphClient._graphBaseUrl = serviceScope
|
|
31
|
-
.consume(sp_http_base_1._GraphHttpClientContext.serviceKey)
|
|
32
|
-
.getGraphEndpointUrl();
|
|
33
|
-
if (!MSGraphClient._instance) {
|
|
34
|
-
MSGraphClient._instance = _this._createGraphClientInstance(sp_http_base_1._AadTokenProviders.configurable);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return MSGraphClient;
|
|
37
9
|
}
|
|
10
|
+
});
|
|
11
|
+
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
12
|
+
const _spcorelibrary = require("@microsoft/sp-core-library");
|
|
13
|
+
const _spdiagnostics = require("@microsoft/sp-diagnostics");
|
|
14
|
+
const _sphttpbase = require("@microsoft/sp-http-base");
|
|
15
|
+
const _SPHttpMsGraphStringsresx = /*#__PURE__*/ _interop_require_default._(require("./SPHttpMsGraphStrings.resx"));
|
|
16
|
+
const _KillSwitches = require("./KillSwitches");
|
|
17
|
+
class MSGraphClient {
|
|
38
18
|
/**
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
19
|
+
* All calls to Microsoft Graph are chained together starting with the api function.
|
|
20
|
+
*
|
|
21
|
+
* @remarks Path supports the following formats:
|
|
22
|
+
* * me
|
|
23
|
+
* * /me
|
|
24
|
+
* * https://graph.microsoft.com/v1.0/me
|
|
25
|
+
* * https://graph.microsoft.com/beta/me
|
|
26
|
+
* * me/events?$filter=startswith(subject, 'ship')
|
|
27
|
+
*
|
|
28
|
+
* The authProvider and baseUrl option should not be used, as they have already been
|
|
29
|
+
* provided by the framework. See the official documentation here:
|
|
30
|
+
* https://github.com/microsoftgraph/msgraph-sdk-javascript
|
|
31
|
+
*
|
|
32
|
+
* @param path - The path for the request to MSGraph.
|
|
33
|
+
* @param config - Sets the configuration for this request.
|
|
34
|
+
*/ api(path, config) {
|
|
35
|
+
_spcorelibrary.Validate.isNonemptyString(path, 'path');
|
|
36
|
+
MSGraphClient._instance.config = {
|
|
37
|
+
...MSGraphClient._originalConfig,
|
|
38
|
+
...config || {}
|
|
39
|
+
};
|
|
58
40
|
return MSGraphClient._instance.api(path);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
var graphClientModule;
|
|
41
|
+
}
|
|
42
|
+
_createGraphClientInstance(tokenProvider) {
|
|
43
|
+
let graphClientModule;
|
|
63
44
|
if (!(MSGraphClient._window.MicrosoftGraph && MSGraphClient._window.MicrosoftGraph.Client)) {
|
|
64
|
-
throw new Error(
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
45
|
+
throw new Error(_SPHttpMsGraphStringsresx.default.graphClientInitializationError);
|
|
46
|
+
} else {
|
|
67
47
|
// Workaround needed to interact with the Client object.
|
|
68
48
|
// See https://github.com/microsoftgraph/msgraph-sdk-javascript/issues/47 for more details
|
|
69
49
|
graphClientModule = MSGraphClient._window.MicrosoftGraph.Client;
|
|
70
50
|
// Removing window variable reference to MSGraphJsSdk object
|
|
71
51
|
MSGraphClient._window.MicrosoftGraph = undefined;
|
|
72
52
|
}
|
|
73
|
-
|
|
74
|
-
authProvider:
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
})
|
|
79
|
-
.catch(function (e) {
|
|
53
|
+
const graphClient = graphClientModule.init({
|
|
54
|
+
authProvider: (done)=>{
|
|
55
|
+
this._getOAuthToken(tokenProvider).then((token)=>{
|
|
56
|
+
done(undefined /** error object */ , token);
|
|
57
|
+
}).catch((e)=>{
|
|
80
58
|
// The IGraphRequest functions will return a rejected promise if it fails to get an OAuth2Token.
|
|
81
59
|
done(e, '');
|
|
82
60
|
});
|
|
@@ -85,22 +63,33 @@ var MSGraphClient = /** @class */ (function () {
|
|
|
85
63
|
});
|
|
86
64
|
MSGraphClient._originalConfig = graphClient.config;
|
|
87
65
|
return graphClient;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
66
|
+
}
|
|
67
|
+
_getOAuthToken(tokenProvider) {
|
|
68
|
+
const qosMonitor = new _spdiagnostics._QosMonitor('MSGraphClient.FetchGraphToken');
|
|
69
|
+
const tokenPromise = !(0, _KillSwitches.isGraphWellKnownResourceKSActive)() ? tokenProvider.getToken(MSGraphClient._graphBaseUrl, {
|
|
70
|
+
wellKnownResource: 'ms-graph'
|
|
71
|
+
}) : tokenProvider.getToken(MSGraphClient._graphBaseUrl);
|
|
72
|
+
return tokenPromise.then((response)=>{
|
|
94
73
|
qosMonitor.writeSuccess();
|
|
95
74
|
return response;
|
|
96
|
-
})
|
|
97
|
-
.catch(function (error) {
|
|
75
|
+
}).catch((error)=>{
|
|
98
76
|
qosMonitor.writeUnexpectedFailure(error.message, error);
|
|
99
77
|
throw error;
|
|
100
78
|
});
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* @param serviceScope - Provides services for the MSGraphClient to consume.
|
|
82
|
+
*
|
|
83
|
+
* @internal
|
|
84
|
+
*/ constructor(serviceScope){
|
|
85
|
+
serviceScope.whenFinished(()=>{
|
|
86
|
+
MSGraphClient._graphBaseUrl = serviceScope.consume(_sphttpbase._GraphHttpClientContext.serviceKey).getGraphEndpointUrl();
|
|
87
|
+
if (!MSGraphClient._instance) {
|
|
88
|
+
MSGraphClient._instance = this._createGraphClientInstance(_sphttpbase._AadTokenProviders.configurable);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
MSGraphClient._window = window;
|
|
94
|
+
|
|
95
|
+
//# sourceMappingURL=./MSGraphClient.js.map
|
|
@@ -1,106 +1,100 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* For more information: {@link https://docs.microsoft.com/en-us/sharepoint/dev/spfx/use-msgraph}
|
|
10
|
-
*
|
|
11
|
-
* @public
|
|
12
|
-
*/
|
|
13
|
-
var MSGraphClientFactory = /** @class */ (function () {
|
|
14
|
-
/**
|
|
15
|
-
* @param serviceScope - Provides services for the MSGraphClient to consume.
|
|
16
|
-
*
|
|
17
|
-
* @internal
|
|
18
|
-
*/
|
|
19
|
-
function MSGraphClientFactory(serviceScope) {
|
|
20
|
-
this._serviceScope = serviceScope;
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return MSGraphClientFactory;
|
|
21
9
|
}
|
|
22
|
-
|
|
23
|
-
|
|
10
|
+
});
|
|
11
|
+
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
12
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
13
|
+
const _spcorelibrary = require("@microsoft/sp-core-library");
|
|
14
|
+
const _spdiagnostics = require("@microsoft/sp-diagnostics");
|
|
15
|
+
const _MSGraphClient = /*#__PURE__*/ _interop_require_default._(require("./MSGraphClient"));
|
|
16
|
+
class MSGraphClientFactory {
|
|
17
|
+
getClient(version, options) {
|
|
24
18
|
if (!version || version === '1') {
|
|
25
19
|
// returns a v1 version of MSGraphClient
|
|
26
|
-
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
/* webpackChunkName: 'sp-http-msgraphclient' */ '@microsoft/microsoft-graph-clientv1/lib/graph-js-sdk-web')); }).then(function () {
|
|
30
|
-
return new MSGraphClient_1.default(_this._serviceScope);
|
|
20
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */ if (!_MSGraphClient.default._instance) {
|
|
21
|
+
return Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard._(require(/* webpackChunkName: 'sp-http-msgraphclient' */ "@microsoft/microsoft-graph-clientv1/lib/graph-js-sdk-web"))).then(()=>{
|
|
22
|
+
return new _MSGraphClient.default(this._serviceScope);
|
|
31
23
|
});
|
|
24
|
+
} else {
|
|
25
|
+
return Promise.resolve(new _MSGraphClient.default(this._serviceScope));
|
|
32
26
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
else if (version === '3' &&
|
|
38
|
-
!sp_core_library_1._SPKillSwitch.isActivated('24401914-15d6-4c3c-aeea-4aace46d5586' /* '01/06/2022', 'use new MSGraphVersion' */)) {
|
|
39
|
-
var qosMonitor_1 = new sp_diagnostics_1._QosMonitor('MSGraphClientFactory.GetClientV3');
|
|
27
|
+
} else if (version === '3' && !_spcorelibrary._SPKillSwitch.isActivated('24401914-15d6-4c3c-aeea-4aace46d5586' /* '01/06/2022', 'use new MSGraphVersion' */ )) {
|
|
28
|
+
const qosMonitor = new _spdiagnostics._QosMonitor('MSGraphClientFactory.GetClientV3');
|
|
40
29
|
// returns a v3 version of MSGraphClient
|
|
41
30
|
// Should only import once no matter how many times it is called
|
|
42
|
-
return Promise.resolve().then(
|
|
31
|
+
return Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard._(require(/* webpackChunkName: 'sp-http-msgraphclientv3' */ "./MSGraphClientV3"))).then((msGraphClientV3)=>{
|
|
43
32
|
// We create a new object every time rather than referencing an existing object in case the service scope changes
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
33
|
+
qosMonitor.writeSuccess({
|
|
34
|
+
version: 3,
|
|
35
|
+
options: !!options
|
|
36
|
+
});
|
|
37
|
+
return new msGraphClientV3.default(this._serviceScope, options, undefined);
|
|
38
|
+
}).catch((error)=>{
|
|
39
|
+
qosMonitor.writeUnexpectedFailure('ImportMSGraphV3ChunkFailed', error);
|
|
49
40
|
throw error;
|
|
50
41
|
});
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
var errorMessage = 'Not yet implemented.';
|
|
42
|
+
} else {
|
|
43
|
+
const errorMessage = 'Not yet implemented.';
|
|
54
44
|
throw Error(errorMessage);
|
|
55
45
|
}
|
|
56
|
-
}
|
|
46
|
+
}
|
|
57
47
|
/**
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
var _this = this;
|
|
66
|
-
var qosMonitor = new sp_diagnostics_1._QosMonitor('MSGraphClientFactory.GetClientV3WithMiddleware');
|
|
48
|
+
* Returns an instance of the MSGraphClient that communicates with the current tenant's configurable Service Pricipal.
|
|
49
|
+
* Allows to specify custom middleware options.
|
|
50
|
+
*
|
|
51
|
+
* @param version - The version of the Graph API to use. 3.
|
|
52
|
+
* @param options - Client options for the Graph API.
|
|
53
|
+
*/ getClientWithMiddleware(version, options) {
|
|
54
|
+
const qosMonitor = new _spdiagnostics._QosMonitor('MSGraphClientFactory.GetClientV3WithMiddleware');
|
|
67
55
|
// returns a v3 version of MSGraphClient
|
|
68
56
|
// Should only import once no matter how many times it is called
|
|
69
|
-
return Promise.resolve().then(
|
|
57
|
+
return Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard._(require(/* webpackChunkName: 'sp-http-msgraphclientv3' */ "./MSGraphClientV3"))).then((msGraphClientV3)=>{
|
|
70
58
|
// We create a new object every time rather than referencing an existing object in case the service scope changes
|
|
71
|
-
qosMonitor.writeSuccess({
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
.
|
|
59
|
+
qosMonitor.writeSuccess({
|
|
60
|
+
version: 3
|
|
61
|
+
});
|
|
62
|
+
return new msGraphClientV3.default(this._serviceScope, undefined, options);
|
|
63
|
+
}).catch((error)=>{
|
|
75
64
|
qosMonitor.writeUnexpectedFailure('ImportMSGraphV3ChunkFailed', error);
|
|
76
65
|
throw error;
|
|
77
66
|
});
|
|
78
|
-
}
|
|
67
|
+
}
|
|
79
68
|
/**
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
var _this = this;
|
|
87
|
-
var qosMonitor = new sp_diagnostics_1._QosMonitor('MSGraphClientFactory.GetInternalClientV3');
|
|
69
|
+
* Returns a v3 version of MSGraphClient with the 1P App Principal
|
|
70
|
+
*
|
|
71
|
+
* @internal
|
|
72
|
+
*
|
|
73
|
+
*/ getClientInternal(version, options) {
|
|
74
|
+
const qosMonitor = new _spdiagnostics._QosMonitor('MSGraphClientFactory.GetInternalClientV3');
|
|
88
75
|
// Should only import once no matter how many times it is called
|
|
89
|
-
return Promise.resolve().then(
|
|
76
|
+
return Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard._(require(/* webpackChunkName: 'sp-http-msgraphclientv3' */ "./MSGraphClientV3"))).then((msGraphClientV3)=>{
|
|
90
77
|
// We create a new object every time rather than referencing an existing object in case the service scope changes
|
|
91
|
-
qosMonitor.writeSuccess({
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
78
|
+
qosMonitor.writeSuccess({
|
|
79
|
+
version: 3,
|
|
80
|
+
options: !!options
|
|
81
|
+
});
|
|
82
|
+
return new msGraphClientV3.default(this._serviceScope, options, undefined, true);
|
|
83
|
+
}).catch((error)=>{
|
|
95
84
|
qosMonitor.writeUnexpectedFailure('ImportMSGraphV3ChunkFailed', error);
|
|
96
85
|
throw error;
|
|
97
86
|
});
|
|
98
|
-
}
|
|
87
|
+
}
|
|
99
88
|
/**
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
89
|
+
* @param serviceScope - Provides services for the MSGraphClient to consume.
|
|
90
|
+
*
|
|
91
|
+
* @internal
|
|
92
|
+
*/ constructor(serviceScope){
|
|
93
|
+
this._serviceScope = serviceScope;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* The service key for MSGraphClientFactory.
|
|
98
|
+
*/ MSGraphClientFactory.serviceKey = _spcorelibrary.ServiceKey.create('sp-http:MSGraphClientFactory', MSGraphClientFactory);
|
|
99
|
+
|
|
100
|
+
//# sourceMappingURL=./MSGraphClientFactory.js.map
|