@microsoft/sp-http-msgraph 1.23.1 → 1.24.0-beta.2

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.
Files changed (49) hide show
  1. package/dist/aec2bbfd-a968-4d5b-a279-12e570f378e6.manifest.json +132 -142
  2. package/dist/chunk.sp-http-msgraphclient_none_c219d50ed0c3718eb04c.js +2 -0
  3. package/dist/chunk.sp-http-msgraphclientv3_none_f69d5240fbc396e22113.js +2 -0
  4. package/dist/sp-http-msgraph_default_b1a01d6b4cff75fbeb8b.js +2 -0
  5. package/dist/sp-http-msgraph_en-us_c25b4ebcf02eb1bfeda7.js +2 -0
  6. package/dist/sp-http-msgraph_qps-ploc_e3ac749f677a1d25e5d1.js +2 -0
  7. package/dist/sp-http-msgraph_qps-ploca_1b3894e46de77590c544.js +2 -0
  8. package/dist/tsdoc-metadata.json +1 -1
  9. package/lib-commonjs/KillSwitches.js +16 -0
  10. package/lib-commonjs/MSGraphAuthenticationProvider.js +39 -33
  11. package/lib-commonjs/MSGraphClient.js +71 -82
  12. package/lib-commonjs/MSGraphClientFactory.js +73 -79
  13. package/lib-commonjs/MSGraphClientV3.js +135 -156
  14. package/lib-commonjs/common/Killswitches.js +26 -16
  15. package/lib-commonjs/index.js +23 -12
  16. package/lib-dts/KillSwitches.d.ts +2 -0
  17. package/lib-esm/KillSwitches.js +6 -0
  18. package/lib-esm/MSGraphAuthenticationProvider.js +49 -0
  19. package/lib-esm/MSGraphClient.js +97 -0
  20. package/lib-esm/MSGraphClientFactory.js +94 -0
  21. package/lib-esm/MSGraphClientV3.js +190 -0
  22. package/{lib → lib-esm}/common/Killswitches.js +5 -10
  23. package/{lib → lib-esm}/index.js +3 -3
  24. package/package.json +41 -10
  25. package/dist/chunk.sp-http-msgraphclient_none_480d82d37e0f32d71f13.js +0 -2
  26. package/dist/chunk.sp-http-msgraphclientv3_none_2f92cf18b28fcffe75bf.js +0 -2
  27. package/dist/sp-http-msgraph_default_984fa6f1d4c9bf26a529.js +0 -1
  28. package/dist/sp-http-msgraph_en-us_cd6999e137b942d4dcb2.js +0 -1
  29. package/dist/sp-http-msgraph_qps-ploc_7350436220b69245f0ce.js +0 -1
  30. package/dist/sp-http-msgraph_qps-ploca_a7714aa16fc1a1bf917d.js +0 -1
  31. package/lib/MSGraphAuthenticationProvider.d.ts.map +0 -1
  32. package/lib/MSGraphAuthenticationProvider.js +0 -50
  33. package/lib/MSGraphClient.d.ts.map +0 -1
  34. package/lib/MSGraphClient.js +0 -104
  35. package/lib/MSGraphClientFactory.d.ts.map +0 -1
  36. package/lib/MSGraphClientFactory.js +0 -106
  37. package/lib/MSGraphClientV3.d.ts.map +0 -1
  38. package/lib/MSGraphClientV3.js +0 -206
  39. package/lib/common/Killswitches.d.ts.map +0 -1
  40. package/lib/index.d.ts.map +0 -1
  41. /package/{lib → lib-dts}/MSGraphAuthenticationProvider.d.ts +0 -0
  42. /package/{lib → lib-dts}/MSGraphClient.d.ts +0 -0
  43. /package/{lib → lib-dts}/MSGraphClientFactory.d.ts +0 -0
  44. /package/{lib → lib-dts}/MSGraphClientV3.d.ts +0 -0
  45. /package/{lib → lib-dts}/SPHttpMsGraphStrings.resx.d.ts +0 -0
  46. /package/{lib → lib-dts}/common/Killswitches.d.ts +0 -0
  47. /package/{lib → lib-dts}/index.d.ts +0 -0
  48. /package/{lib → lib-esm}/SPHttpMsGraphStrings.resx.json +0 -0
  49. /package/{lib → lib-esm}/sp-http-msgraph.manifest.json +0 -0
@@ -1,82 +1,60 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- var sp_core_library_1 = require("@microsoft/sp-core-library");
5
- var sp_diagnostics_1 = require("@microsoft/sp-diagnostics");
6
- var sp_http_base_1 = require("@microsoft/sp-http-base");
7
- var SPHttpMsGraphStrings_resx_1 = tslib_1.__importDefault(require("./SPHttpMsGraphStrings.resx"));
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
- * All calls to Microsoft Graph are chained together starting with the api function.
40
- *
41
- * @remarks Path supports the following formats:
42
- * * me
43
- * * /me
44
- * * https://graph.microsoft.com/v1.0/me
45
- * * https://graph.microsoft.com/beta/me
46
- * * me/events?$filter=startswith(subject, 'ship')
47
- *
48
- * The authProvider and baseUrl option should not be used, as they have already been
49
- * provided by the framework. See the official documentation here:
50
- * https://github.com/microsoftgraph/msgraph-sdk-javascript
51
- *
52
- * @param path - The path for the request to MSGraph.
53
- * @param config - Sets the configuration for this request.
54
- */
55
- MSGraphClient.prototype.api = function (path, config) {
56
- sp_core_library_1.Validate.isNonemptyString(path, 'path');
57
- MSGraphClient._instance.config = tslib_1.__assign(tslib_1.__assign({}, MSGraphClient._originalConfig), (config || {}));
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
- MSGraphClient.prototype._createGraphClientInstance = function (tokenProvider) {
61
- var _this = this;
62
- var graphClientModule;
41
+ }
42
+ _createGraphClientInstance(tokenProvider) {
43
+ let graphClientModule;
63
44
  if (!(MSGraphClient._window.MicrosoftGraph && MSGraphClient._window.MicrosoftGraph.Client)) {
64
- throw new Error(SPHttpMsGraphStrings_resx_1.default.graphClientInitializationError);
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
- var graphClient = graphClientModule.init({
74
- authProvider: function (done) {
75
- _this._getOAuthToken(tokenProvider)
76
- .then(function (token) {
77
- done(undefined /** error object */, token);
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
- MSGraphClient.prototype._getOAuthToken = function (tokenProvider) {
90
- var qosMonitor = new sp_diagnostics_1._QosMonitor('MSGraphClient.FetchGraphToken');
91
- return tokenProvider
92
- .getToken(MSGraphClient._graphBaseUrl)
93
- .then(function (response) {
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
- MSGraphClient._window = window;
103
- return MSGraphClient;
104
- }());
105
- exports.default = MSGraphClient;
106
- //# sourceMappingURL=MSGraphClient.js.map
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", { value: true });
3
- var tslib_1 = require("tslib");
4
- var sp_core_library_1 = require("@microsoft/sp-core-library");
5
- var sp_diagnostics_1 = require("@microsoft/sp-diagnostics");
6
- var MSGraphClient_1 = tslib_1.__importDefault(require("./MSGraphClient"));
7
- /**
8
- * Returns a preinitialized version of the MSGraphClient.
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
- MSGraphClientFactory.prototype.getClient = function (version, options) {
23
- var _this = this;
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
- if (!MSGraphClient_1.default._instance) {
28
- return Promise.resolve().then(function () { return tslib_1.__importStar(require(
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
- else {
34
- return Promise.resolve(new MSGraphClient_1.default(this._serviceScope));
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(function () { return tslib_1.__importStar(require(/* webpackChunkName: 'sp-http-msgraphclientv3' */ './MSGraphClientV3')); }).then(function (msGraphClientV3) {
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
- qosMonitor_1.writeSuccess({ version: 3, options: !!options });
45
- return new msGraphClientV3.default(_this._serviceScope, options, undefined);
46
- })
47
- .catch(function (error) {
48
- qosMonitor_1.writeUnexpectedFailure('ImportMSGraphV3ChunkFailed', error);
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
- else {
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
- * Returns an instance of the MSGraphClient that communicates with the current tenant's configurable Service Pricipal.
59
- * Allows to specify custom middleware options.
60
- *
61
- * @param version - The version of the Graph API to use. 3.
62
- * @param options - Client options for the Graph API.
63
- */
64
- MSGraphClientFactory.prototype.getClientWithMiddleware = function (version, options) {
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(function () { return tslib_1.__importStar(require(/* webpackChunkName: 'sp-http-msgraphclientv3' */ './MSGraphClientV3')); }).then(function (msGraphClientV3) {
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({ version: 3 });
72
- return new msGraphClientV3.default(_this._serviceScope, undefined, options);
73
- })
74
- .catch(function (error) {
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
- * Returns a v3 version of MSGraphClient with the 1P App Principal
81
- *
82
- * @internal
83
- *
84
- */
85
- MSGraphClientFactory.prototype.getClientInternal = function (version, options) {
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(function () { return tslib_1.__importStar(require(/* webpackChunkName: 'sp-http-msgraphclientv3' */ './MSGraphClientV3')); }).then(function (msGraphClientV3) {
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({ version: 3, options: !!options });
92
- return new msGraphClientV3.default(_this._serviceScope, options, undefined, true);
93
- })
94
- .catch(function (error) {
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
- * The service key for MSGraphClientFactory.
101
- */
102
- MSGraphClientFactory.serviceKey = sp_core_library_1.ServiceKey.create('sp-http:MSGraphClientFactory', MSGraphClientFactory);
103
- return MSGraphClientFactory;
104
- }());
105
- exports.default = MSGraphClientFactory;
106
- //# sourceMappingURL=MSGraphClientFactory.js.map
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