@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,106 +0,0 @@
1
- import { ServiceKey, _SPKillSwitch } from '@microsoft/sp-core-library';
2
- import { _QosMonitor } from '@microsoft/sp-diagnostics';
3
- import MSGraphClient from './MSGraphClient';
4
- /**
5
- * Returns a preinitialized version of the MSGraphClient.
6
- * For more information: {@link https://docs.microsoft.com/en-us/sharepoint/dev/spfx/use-msgraph}
7
- *
8
- * @public
9
- */
10
- var MSGraphClientFactory = /** @class */ (function () {
11
- /**
12
- * @param serviceScope - Provides services for the MSGraphClient to consume.
13
- *
14
- * @internal
15
- */
16
- function MSGraphClientFactory(serviceScope) {
17
- this._serviceScope = serviceScope;
18
- }
19
- MSGraphClientFactory.prototype.getClient = function (version, options) {
20
- var _this = this;
21
- if (!version || version === '1') {
22
- // returns a v1 version of MSGraphClient
23
- /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
24
- if (!MSGraphClient._instance) {
25
- return import(
26
- /* webpackChunkName: 'sp-http-msgraphclient' */ '@microsoft/microsoft-graph-clientv1/lib/graph-js-sdk-web').then(function () {
27
- return new MSGraphClient(_this._serviceScope);
28
- });
29
- }
30
- else {
31
- return Promise.resolve(new MSGraphClient(this._serviceScope));
32
- }
33
- }
34
- else if (version === '3' &&
35
- !_SPKillSwitch.isActivated('24401914-15d6-4c3c-aeea-4aace46d5586' /* '01/06/2022', 'use new MSGraphVersion' */)) {
36
- var qosMonitor_1 = new _QosMonitor('MSGraphClientFactory.GetClientV3');
37
- // returns a v3 version of MSGraphClient
38
- // Should only import once no matter how many times it is called
39
- return import(/* webpackChunkName: 'sp-http-msgraphclientv3' */ './MSGraphClientV3')
40
- .then(function (msGraphClientV3) {
41
- // We create a new object every time rather than referencing an existing object in case the service scope changes
42
- qosMonitor_1.writeSuccess({ version: 3, options: !!options });
43
- return new msGraphClientV3.default(_this._serviceScope, options, undefined);
44
- })
45
- .catch(function (error) {
46
- qosMonitor_1.writeUnexpectedFailure('ImportMSGraphV3ChunkFailed', error);
47
- throw error;
48
- });
49
- }
50
- else {
51
- var errorMessage = 'Not yet implemented.';
52
- throw Error(errorMessage);
53
- }
54
- };
55
- /**
56
- * Returns an instance of the MSGraphClient that communicates with the current tenant's configurable Service Pricipal.
57
- * Allows to specify custom middleware options.
58
- *
59
- * @param version - The version of the Graph API to use. 3.
60
- * @param options - Client options for the Graph API.
61
- */
62
- MSGraphClientFactory.prototype.getClientWithMiddleware = function (version, options) {
63
- var _this = this;
64
- var qosMonitor = new _QosMonitor('MSGraphClientFactory.GetClientV3WithMiddleware');
65
- // returns a v3 version of MSGraphClient
66
- // Should only import once no matter how many times it is called
67
- return import(/* webpackChunkName: 'sp-http-msgraphclientv3' */ './MSGraphClientV3')
68
- .then(function (msGraphClientV3) {
69
- // We create a new object every time rather than referencing an existing object in case the service scope changes
70
- qosMonitor.writeSuccess({ version: 3 });
71
- return new msGraphClientV3.default(_this._serviceScope, undefined, options);
72
- })
73
- .catch(function (error) {
74
- qosMonitor.writeUnexpectedFailure('ImportMSGraphV3ChunkFailed', error);
75
- throw error;
76
- });
77
- };
78
- /**
79
- * Returns a v3 version of MSGraphClient with the 1P App Principal
80
- *
81
- * @internal
82
- *
83
- */
84
- MSGraphClientFactory.prototype.getClientInternal = function (version, options) {
85
- var _this = this;
86
- var qosMonitor = new _QosMonitor('MSGraphClientFactory.GetInternalClientV3');
87
- // Should only import once no matter how many times it is called
88
- return import(/* webpackChunkName: 'sp-http-msgraphclientv3' */ './MSGraphClientV3')
89
- .then(function (msGraphClientV3) {
90
- // 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) {
95
- qosMonitor.writeUnexpectedFailure('ImportMSGraphV3ChunkFailed', error);
96
- throw error;
97
- });
98
- };
99
- /**
100
- * The service key for MSGraphClientFactory.
101
- */
102
- MSGraphClientFactory.serviceKey = ServiceKey.create('sp-http:MSGraphClientFactory', MSGraphClientFactory);
103
- return MSGraphClientFactory;
104
- }());
105
- export default MSGraphClientFactory;
106
- //# sourceMappingURL=MSGraphClientFactory.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MSGraphClientV3.d.ts","sourceRoot":"","sources":["../src/MSGraphClientV3.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,YAAY,EAAY,MAAM,4BAA4B,CAAC;AAE9F,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,OAAO,EACP,MAAM,EAEP,MAAM,mCAAmC,CAAC;AAqB3C;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,OAAO,OAAO,eAAe;IAClC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAS;IACjC,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAS;IACzC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAS;IAErC,OAAO,CAAC,WAAW,CAAkB;IACrC,OAAO,CAAC,0BAA0B,CAA2C;IAC7E,OAAO,CAAC,mBAAmB,CAAoC;IAE/D;;;;OAIG;gBAED,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,OAAO,GAAG,SAAS,EAC5B,aAAa,EAAE,aAAa,GAAG,SAAS,EACxC,cAAc,CAAC,EAAE,OAAO;IA0C1B;;;;;;;;;;;;;;;OAeG;IACI,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY;IAiBtC;;OAEG;IACH,IAAW,MAAM,IAAI,MAAM,CAK1B;IAED,OAAO,CAAC,0BAA0B;IAqBlC,OAAO,CAAC,wCAAwC;IAmBhD,OAAO,CAAC,kCAAkC;IAoB1C,OAAO,CAAC,qBAAqB;CAyE9B"}
@@ -1,206 +0,0 @@
1
- import { __assign } from "tslib";
2
- import { _ClientManifestData, Validate } from '@microsoft/sp-core-library';
3
- import { _QosMonitor } from '@microsoft/sp-diagnostics';
4
- import { Client as _InternalGraphClient, AuthenticationHandler, MiddlewareFactory } from '@msinternal/ms-graph-v3-bundle';
5
- import { _GraphHttpClientContext, _AadTokenProviders, _SPRequestRateMonitor } from '@microsoft/sp-http-base';
6
- import { isCustomHostsKSActivated, isPassSdkVersionKSActivated, isRequestRateMonitorKSActivated } from './common/Killswitches';
7
- import { MSGraphAuthenticationProvider } from './MSGraphAuthenticationProvider';
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 MSGraphClientV3 = /** @class */ (function () {
22
- /**
23
- * @param serviceScope - Provides services for the MSGraphClient to consume.
24
- *
25
- * @internal
26
- */
27
- function MSGraphClientV3(serviceScope, options, clientOptions, internalClient) {
28
- var _this = this;
29
- this._isInternal = false;
30
- serviceScope.whenFinished(function () {
31
- if (!MSGraphClientV3._graphBaseUrl) {
32
- MSGraphClientV3._graphBaseUrl = serviceScope
33
- .consume(_GraphHttpClientContext.serviceKey)
34
- .getGraphEndpointUrl();
35
- }
36
- if (!isPassSdkVersionKSActivated()) {
37
- var clientManifestData = serviceScope.consume(_ClientManifestData.serviceKey);
38
- _this._consumerComponentManifest = clientManifestData.manifest;
39
- }
40
- if (!isRequestRateMonitorKSActivated()) {
41
- _this._requestRateMonitor = serviceScope.consume(_SPRequestRateMonitor.serviceKey);
42
- }
43
- if (internalClient) {
44
- _this._isInternal = true;
45
- if (!MSGraphClientV3._internalInstance) {
46
- MSGraphClientV3._internalInstance = _this._createInternalGraphClientInstance(_AadTokenProviders.configurable, options);
47
- }
48
- }
49
- else if (!MSGraphClientV3._instance) {
50
- if (clientOptions !== undefined) {
51
- MSGraphClientV3._instance = _this._createGraphClientInstanceWithMiddleware(_AadTokenProviders.configurable, clientOptions);
52
- }
53
- else {
54
- MSGraphClientV3._instance = _this._createGraphClientInstance(_AadTokenProviders.configurable, options);
55
- }
56
- }
57
- });
58
- }
59
- /**
60
- * All calls to Microsoft Graph are chained together starting with the api function.
61
- *
62
- * @remarks Path supports the following formats:
63
- * * me
64
- * * /me
65
- * * https://graph.microsoft.com/v1.0/me
66
- * * https://graph.microsoft.com/beta/me
67
- * * me/events?$filter=startswith(subject, 'ship')
68
- *
69
- * The authProvider and baseUrl option should not be used, as they have already been
70
- * provided by the framework. See the official documentation here:
71
- * https://github.com/microsoftgraph/msgraph-sdk-javascript
72
- *
73
- * @param path - The path for the request to MSGraph.
74
- */
75
- MSGraphClientV3.prototype.api = function (path) {
76
- Validate.isNonemptyString(path, 'path');
77
- if (!isRequestRateMonitorKSActivated() && this._requestRateMonitor && this._consumerComponentManifest) {
78
- var _a = this._consumerComponentManifest, componentType = _a.componentType, alias = _a.alias, id = _a.id;
79
- if (componentType === 'WebPart' || componentType === 'AdaptiveCardExtension') {
80
- var trackingUrl = path.startsWith('http')
81
- ? path
82
- : new URL(path.replace(/^\//, ''), MSGraphClientV3._graphBaseUrl).href;
83
- this._requestRateMonitor.trackRequest(trackingUrl, "".concat(componentType, ".").concat(alias, ".").concat(id));
84
- }
85
- }
86
- if (this._isInternal) {
87
- return MSGraphClientV3._internalInstance.api(path);
88
- }
89
- return MSGraphClientV3._instance.api(path);
90
- };
91
- Object.defineProperty(MSGraphClientV3.prototype, "client", {
92
- /**
93
- * Gets the instance of the instantiated Client object from Microsoft Graph SDK.
94
- */
95
- get: function () {
96
- if (this._isInternal) {
97
- return MSGraphClientV3._internalInstance;
98
- }
99
- return MSGraphClientV3._instance;
100
- },
101
- enumerable: false,
102
- configurable: true
103
- });
104
- MSGraphClientV3.prototype._createGraphClientInstance = function (tokenProvider, options) {
105
- var qosMonitor = new _QosMonitor('MSGraphClientV3.CreateGraphClientInstance');
106
- var graphClient;
107
- try {
108
- graphClient = this._createClientInstance(__assign(__assign({}, options), { authProvider: undefined }), tokenProvider, false);
109
- }
110
- catch (e) {
111
- qosMonitor.writeUnexpectedFailure(e.message, e);
112
- throw e;
113
- }
114
- return graphClient;
115
- };
116
- MSGraphClientV3.prototype._createGraphClientInstanceWithMiddleware = function (tokenProvider, options) {
117
- var qosMonitor = new _QosMonitor('MSGraphClientV3.CreateGraphClientInstanceWithMiddleware');
118
- var graphClient;
119
- try {
120
- graphClient = this._createClientInstance(options, tokenProvider, false);
121
- qosMonitor.writeSuccess();
122
- return graphClient;
123
- }
124
- catch (e) {
125
- qosMonitor.writeUnexpectedFailure(e.message, e);
126
- throw e;
127
- }
128
- };
129
- MSGraphClientV3.prototype._createInternalGraphClientInstance = function (tokenProvider, options) {
130
- var qosMonitor = new _QosMonitor('MSGraphClientV3.CreateInternalGraphClientInstance');
131
- var graphClient;
132
- try {
133
- graphClient = this._createClientInstance(__assign(__assign({}, options), { authProvider: undefined }), tokenProvider, true);
134
- }
135
- catch (e) {
136
- qosMonitor.writeUnexpectedFailure(e.message, e);
137
- throw e;
138
- }
139
- return graphClient;
140
- };
141
- MSGraphClientV3.prototype._createClientInstance = function (options, tokenProvider, isInternal) {
142
- var clientOptions = options || {};
143
- clientOptions.baseUrl = MSGraphClientV3._graphBaseUrl;
144
- var middlewareChain;
145
- if (!clientOptions.middleware) {
146
- // creating default chain
147
- middlewareChain = MiddlewareFactory.getDefaultMiddlewareChain(new MSGraphAuthenticationProvider(tokenProvider, MSGraphClientV3._graphBaseUrl, isInternal));
148
- }
149
- else {
150
- // a developer has provided middleware(s)
151
- var authMiddleware = new AuthenticationHandler(new MSGraphAuthenticationProvider(tokenProvider, MSGraphClientV3._graphBaseUrl, isInternal));
152
- middlewareChain = [authMiddleware];
153
- if (Array.isArray(clientOptions.middleware)) {
154
- middlewareChain.push.apply(middlewareChain, clientOptions.middleware);
155
- }
156
- else {
157
- middlewareChain.push(clientOptions.middleware);
158
- }
159
- }
160
- if (!isPassSdkVersionKSActivated() && this._consumerComponentManifest) {
161
- if (!clientOptions.fetchOptions) {
162
- clientOptions.fetchOptions = {};
163
- }
164
- if (!clientOptions.fetchOptions.headers) {
165
- clientOptions.fetchOptions.headers = {};
166
- }
167
- var sdkVersionValue = "SPFx/".concat(this._consumerComponentManifest.alias, "/").concat(this._consumerComponentManifest.id, "/Is3PRequest:").concat(this._consumerComponentManifest.isInternal ? '0' : '1');
168
- var headers = clientOptions.fetchOptions.headers;
169
- if (Array.isArray(headers)) {
170
- var sdkVersionHeaderIndex = headers.findIndex(function (header) { return header[0] === 'SdkVersion'; });
171
- if (sdkVersionHeaderIndex === -1) {
172
- headers.push(['SdkVersion', sdkVersionValue]);
173
- }
174
- else {
175
- headers[sdkVersionHeaderIndex][1] += ", ".concat(sdkVersionValue);
176
- }
177
- }
178
- else if (headers instanceof Headers) {
179
- headers.has('SdkVersion')
180
- ? headers.set('SdkVersion', "".concat(headers.get('SdkVersion'), ", ").concat(sdkVersionValue))
181
- : headers.set('SdkVersion', sdkVersionValue);
182
- }
183
- else {
184
- headers.SdkVersion = headers.SdkVersions
185
- ? "".concat(headers.SdkVersion, ", ").concat(sdkVersionValue)
186
- : sdkVersionValue;
187
- }
188
- }
189
- // we can add more middleware to the end of the chain here
190
- clientOptions.middleware = middlewareChain;
191
- if (!isCustomHostsKSActivated()) {
192
- try {
193
- var url = new URL(MSGraphClientV3._graphBaseUrl);
194
- clientOptions.customHosts = new Set([url.host]);
195
- }
196
- catch (e) {
197
- var qosMonitor = new _QosMonitor('MSGraphClientV3.CustomHostsAdditionsFailed');
198
- qosMonitor.writeUnexpectedFailure(e.message, e);
199
- }
200
- }
201
- return _InternalGraphClient.initWithMiddleware(clientOptions);
202
- };
203
- return MSGraphClientV3;
204
- }());
205
- export default MSGraphClientV3;
206
- //# sourceMappingURL=MSGraphClientV3.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Killswitches.d.ts","sourceRoot":"","sources":["../../src/common/Killswitches.ts"],"names":[],"mappings":"AAEA,wBAAgB,2BAA2B,IAAI,OAAO,CAKrD;AAED,wBAAgB,wBAAwB,IAAI,OAAO,CAKlD;AAED,wBAAgB,+BAA+B,IAAI,OAAO,CAKzD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,KAAK,aAAa,IAAI,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/F,YAAY,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,wBAAwB,CAAC"}
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes