@microsoft/sp-http-msgraph 1.22.0-beta.1 → 1.22.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 +128 -128
- package/dist/sp-http-msgraph_default_fd5e59edceff825885a9.js +1 -0
- package/dist/sp-http-msgraph_en-us_a2c332cf36198dbffbd9.js +1 -0
- package/dist/sp-http-msgraph_qps-ploc_7ba20fbebf39d1ceb228.js +1 -0
- package/dist/sp-http-msgraph_qps-ploca_d610f6e5163f549c5d3f.js +1 -0
- package/lib/MSGraphAuthenticationProvider.d.ts +12 -0
- package/lib/MSGraphAuthenticationProvider.d.ts.map +1 -0
- package/lib/MSGraphAuthenticationProvider.js +50 -0
- package/lib/MSGraphClient.d.ts +124 -0
- package/lib/MSGraphClient.d.ts.map +1 -0
- package/lib/MSGraphClient.js +104 -0
- package/lib/MSGraphClientFactory.d.ts +55 -0
- package/lib/MSGraphClientFactory.d.ts.map +1 -0
- package/lib/MSGraphClientFactory.js +106 -0
- package/lib/MSGraphClientV3.d.ts +54 -0
- package/lib/MSGraphClientV3.d.ts.map +1 -0
- package/lib/MSGraphClientV3.js +194 -0
- package/lib/SPHttpMsGraphStrings.resx.d.ts +19 -0
- package/lib/SPHttpMsGraphStrings.resx.json +1 -0
- package/lib/common/Killswitches.d.ts +3 -0
- package/lib/common/Killswitches.d.ts.map +1 -0
- package/lib/common/Killswitches.js +12 -0
- package/lib/index.d.ts +13 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +12 -0
- package/lib/sp-http-msgraph.manifest.json +14 -0
- package/package.json +9 -9
- package/dist/sp-http-msgraph_default_4df746036332a4387437.js +0 -1
- package/dist/sp-http-msgraph_en-us_ac1fb9f51f76bafaf211.js +0 -1
- package/dist/sp-http-msgraph_qps-ploc_33b301b92c5a0e988c49.js +0 -1
- package/dist/sp-http-msgraph_qps-ploca_94a48b31e48512284936.js +0 -1
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import type { GraphRequestCallback, Options, URLComponents } from '@microsoft/microsoft-graph-clientv1';
|
|
2
|
+
import { type ServiceScope } from '@microsoft/sp-core-library';
|
|
3
|
+
/**
|
|
4
|
+
* Represents the global singleton object on the window after loading the MS Graph SDK
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export interface IMSGraphClientModule {
|
|
8
|
+
init(options: Options): IMSGraphClient;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Interface for the MSGraphClient.
|
|
12
|
+
* @privateRemarks
|
|
13
|
+
* The original typings cause a build error with webpack.
|
|
14
|
+
*
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
export interface IMSGraphClient {
|
|
18
|
+
config: Options;
|
|
19
|
+
api(path: string): IGraphRequest;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Interface for working with MSGraphClient
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
export interface IWindowWithMSGraphSDK extends Window {
|
|
26
|
+
MicrosoftGraph: {
|
|
27
|
+
Client: IMSGraphClientModule;
|
|
28
|
+
} | undefined;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Typings for the GraphRequest Object
|
|
32
|
+
* For more information: {@link https://github.com/microsoftgraph/msgraph-sdk-javascript}
|
|
33
|
+
*
|
|
34
|
+
* @privateRemarks
|
|
35
|
+
* The original typings include references to polyfills.
|
|
36
|
+
* Exporting the microsoft-graph-client defined class may add unnecessary code to the build.
|
|
37
|
+
* Thefore, we export this interface as `GraphRequest` with the desired API described.
|
|
38
|
+
*
|
|
39
|
+
* @public
|
|
40
|
+
*/
|
|
41
|
+
export interface IGraphRequest {
|
|
42
|
+
config: Options;
|
|
43
|
+
urlComponents: URLComponents;
|
|
44
|
+
_headers: {
|
|
45
|
+
[key: string]: string | number;
|
|
46
|
+
};
|
|
47
|
+
_responseType: string;
|
|
48
|
+
constructor(config: Options, path: string): IGraphRequest;
|
|
49
|
+
header(headerKey: string, headerValue: string): this;
|
|
50
|
+
headers(headers: {
|
|
51
|
+
[key: string]: string | number;
|
|
52
|
+
}): this;
|
|
53
|
+
parsePath(rawPath: string): void;
|
|
54
|
+
buildFullUrl(): string;
|
|
55
|
+
version(v: string): IGraphRequest;
|
|
56
|
+
select(properties: string | string[]): IGraphRequest;
|
|
57
|
+
expand(properties: string | string[]): IGraphRequest;
|
|
58
|
+
orderby(properties: string | string[]): IGraphRequest;
|
|
59
|
+
filter(filterStr: string): IGraphRequest;
|
|
60
|
+
top(n: number): IGraphRequest;
|
|
61
|
+
skip(n: number): IGraphRequest;
|
|
62
|
+
skipToken(token: string): IGraphRequest;
|
|
63
|
+
count(count: boolean): IGraphRequest;
|
|
64
|
+
responseType(responseType: string): IGraphRequest;
|
|
65
|
+
delete(callback?: GraphRequestCallback): Promise<any>;
|
|
66
|
+
patch(content: any, callback?: GraphRequestCallback): Promise<any>;
|
|
67
|
+
post(content: any, callback?: GraphRequestCallback): Promise<any>;
|
|
68
|
+
put(content: any, callback?: GraphRequestCallback): Promise<any>;
|
|
69
|
+
create(content: any, callback?: GraphRequestCallback): Promise<any>;
|
|
70
|
+
update(content: any, callback?: GraphRequestCallback): Promise<any>;
|
|
71
|
+
del(callback?: GraphRequestCallback): Promise<any>;
|
|
72
|
+
get(callback?: GraphRequestCallback): Promise<any>;
|
|
73
|
+
getStream(callback: GraphRequestCallback): void;
|
|
74
|
+
putStream(stream: any, callback: GraphRequestCallback): void;
|
|
75
|
+
query(queryDictionaryOrString: string | {
|
|
76
|
+
[key: string]: string | number;
|
|
77
|
+
}): IGraphRequest;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* MSGraphClient is used to perform REST calls against Microsoft Graph.
|
|
81
|
+
*
|
|
82
|
+
* @remarks The Microsoft Graph JavaScript client library is a lightweight wrapper around the
|
|
83
|
+
* Microsoft Graph API. This class allows developers to start making REST calls to MSGraph without
|
|
84
|
+
* needing to initialize the the MSGraph client library. If a custom configuration is desired,
|
|
85
|
+
* the MSGraphClient api function needs to be provided with that custom configuration for
|
|
86
|
+
* every request.
|
|
87
|
+
*
|
|
88
|
+
* For more information: {@link https://github.com/microsoftgraph/msgraph-sdk-javascript}
|
|
89
|
+
*
|
|
90
|
+
* @public
|
|
91
|
+
*/
|
|
92
|
+
export default class MSGraphClient {
|
|
93
|
+
private static _instance;
|
|
94
|
+
private static _window;
|
|
95
|
+
private static _originalConfig;
|
|
96
|
+
private static _graphBaseUrl;
|
|
97
|
+
/**
|
|
98
|
+
* @param serviceScope - Provides services for the MSGraphClient to consume.
|
|
99
|
+
*
|
|
100
|
+
* @internal
|
|
101
|
+
*/
|
|
102
|
+
constructor(serviceScope: ServiceScope);
|
|
103
|
+
/**
|
|
104
|
+
* All calls to Microsoft Graph are chained together starting with the api function.
|
|
105
|
+
*
|
|
106
|
+
* @remarks Path supports the following formats:
|
|
107
|
+
* * me
|
|
108
|
+
* * /me
|
|
109
|
+
* * https://graph.microsoft.com/v1.0/me
|
|
110
|
+
* * https://graph.microsoft.com/beta/me
|
|
111
|
+
* * me/events?$filter=startswith(subject, 'ship')
|
|
112
|
+
*
|
|
113
|
+
* The authProvider and baseUrl option should not be used, as they have already been
|
|
114
|
+
* provided by the framework. See the official documentation here:
|
|
115
|
+
* https://github.com/microsoftgraph/msgraph-sdk-javascript
|
|
116
|
+
*
|
|
117
|
+
* @param path - The path for the request to MSGraph.
|
|
118
|
+
* @param config - Sets the configuration for this request.
|
|
119
|
+
*/
|
|
120
|
+
api(path: string, config?: Options): IGraphRequest;
|
|
121
|
+
private _createGraphClientInstance;
|
|
122
|
+
private _getOAuthToken;
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=MSGraphClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MSGraphClient.d.ts","sourceRoot":"","sources":["../src/MSGraphClient.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import { Validate } from '@microsoft/sp-core-library';
|
|
3
|
+
import { _QosMonitor } from '@microsoft/sp-diagnostics';
|
|
4
|
+
import { _GraphHttpClientContext, _AadTokenProviders } from '@microsoft/sp-http-base';
|
|
5
|
+
import strings from './SPHttpMsGraphStrings.resx';
|
|
6
|
+
/**
|
|
7
|
+
* MSGraphClient is used to perform REST calls against Microsoft Graph.
|
|
8
|
+
*
|
|
9
|
+
* @remarks The Microsoft Graph JavaScript client library is a lightweight wrapper around the
|
|
10
|
+
* Microsoft Graph API. This class allows developers to start making REST calls to MSGraph without
|
|
11
|
+
* needing to initialize the the MSGraph client library. If a custom configuration is desired,
|
|
12
|
+
* the MSGraphClient api function needs to be provided with that custom configuration for
|
|
13
|
+
* every request.
|
|
14
|
+
*
|
|
15
|
+
* For more information: {@link https://github.com/microsoftgraph/msgraph-sdk-javascript}
|
|
16
|
+
*
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
var MSGraphClient = /** @class */ (function () {
|
|
20
|
+
/**
|
|
21
|
+
* @param serviceScope - Provides services for the MSGraphClient to consume.
|
|
22
|
+
*
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
function MSGraphClient(serviceScope) {
|
|
26
|
+
var _this = this;
|
|
27
|
+
serviceScope.whenFinished(function () {
|
|
28
|
+
MSGraphClient._graphBaseUrl = serviceScope
|
|
29
|
+
.consume(_GraphHttpClientContext.serviceKey)
|
|
30
|
+
.getGraphEndpointUrl();
|
|
31
|
+
if (!MSGraphClient._instance) {
|
|
32
|
+
MSGraphClient._instance = _this._createGraphClientInstance(_AadTokenProviders.configurable);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* All calls to Microsoft Graph are chained together starting with the api function.
|
|
38
|
+
*
|
|
39
|
+
* @remarks Path supports the following formats:
|
|
40
|
+
* * me
|
|
41
|
+
* * /me
|
|
42
|
+
* * https://graph.microsoft.com/v1.0/me
|
|
43
|
+
* * https://graph.microsoft.com/beta/me
|
|
44
|
+
* * me/events?$filter=startswith(subject, 'ship')
|
|
45
|
+
*
|
|
46
|
+
* The authProvider and baseUrl option should not be used, as they have already been
|
|
47
|
+
* provided by the framework. See the official documentation here:
|
|
48
|
+
* https://github.com/microsoftgraph/msgraph-sdk-javascript
|
|
49
|
+
*
|
|
50
|
+
* @param path - The path for the request to MSGraph.
|
|
51
|
+
* @param config - Sets the configuration for this request.
|
|
52
|
+
*/
|
|
53
|
+
MSGraphClient.prototype.api = function (path, config) {
|
|
54
|
+
Validate.isNonemptyString(path, 'path');
|
|
55
|
+
MSGraphClient._instance.config = __assign(__assign({}, MSGraphClient._originalConfig), (config || {}));
|
|
56
|
+
return MSGraphClient._instance.api(path);
|
|
57
|
+
};
|
|
58
|
+
MSGraphClient.prototype._createGraphClientInstance = function (tokenProvider) {
|
|
59
|
+
var _this = this;
|
|
60
|
+
var graphClientModule;
|
|
61
|
+
if (!(MSGraphClient._window.MicrosoftGraph && MSGraphClient._window.MicrosoftGraph.Client)) {
|
|
62
|
+
throw new Error(strings.graphClientInitializationError);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
// Workaround needed to interact with the Client object.
|
|
66
|
+
// See https://github.com/microsoftgraph/msgraph-sdk-javascript/issues/47 for more details
|
|
67
|
+
graphClientModule = MSGraphClient._window.MicrosoftGraph.Client;
|
|
68
|
+
// Removing window variable reference to MSGraphJsSdk object
|
|
69
|
+
MSGraphClient._window.MicrosoftGraph = undefined;
|
|
70
|
+
}
|
|
71
|
+
var graphClient = graphClientModule.init({
|
|
72
|
+
authProvider: function (done) {
|
|
73
|
+
_this._getOAuthToken(tokenProvider)
|
|
74
|
+
.then(function (token) {
|
|
75
|
+
done(undefined /** error object */, token);
|
|
76
|
+
})
|
|
77
|
+
.catch(function (e) {
|
|
78
|
+
// The IGraphRequest functions will return a rejected promise if it fails to get an OAuth2Token.
|
|
79
|
+
done(e, '');
|
|
80
|
+
});
|
|
81
|
+
},
|
|
82
|
+
baseUrl: MSGraphClient._graphBaseUrl
|
|
83
|
+
});
|
|
84
|
+
MSGraphClient._originalConfig = graphClient.config;
|
|
85
|
+
return graphClient;
|
|
86
|
+
};
|
|
87
|
+
MSGraphClient.prototype._getOAuthToken = function (tokenProvider) {
|
|
88
|
+
var qosMonitor = new _QosMonitor('MSGraphClient.FetchGraphToken');
|
|
89
|
+
return tokenProvider
|
|
90
|
+
.getToken(MSGraphClient._graphBaseUrl)
|
|
91
|
+
.then(function (response) {
|
|
92
|
+
qosMonitor.writeSuccess();
|
|
93
|
+
return response;
|
|
94
|
+
})
|
|
95
|
+
.catch(function (error) {
|
|
96
|
+
qosMonitor.writeUnexpectedFailure(error.message, error);
|
|
97
|
+
throw error;
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
MSGraphClient._window = window;
|
|
101
|
+
return MSGraphClient;
|
|
102
|
+
}());
|
|
103
|
+
export default MSGraphClient;
|
|
104
|
+
//# sourceMappingURL=MSGraphClient.js.map
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { ClientOptions, Options } from '@microsoft/microsoft-graph-client';
|
|
2
|
+
import { ServiceKey, type ServiceScope } from '@microsoft/sp-core-library';
|
|
3
|
+
import MSGraphClient from './MSGraphClient';
|
|
4
|
+
import type MSGraphClientV3 from './MSGraphClientV3';
|
|
5
|
+
/**
|
|
6
|
+
* Returns a preinitialized version of the MSGraphClient.
|
|
7
|
+
* For more information: {@link https://docs.microsoft.com/en-us/sharepoint/dev/spfx/use-msgraph}
|
|
8
|
+
*
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export default class MSGraphClientFactory {
|
|
12
|
+
/**
|
|
13
|
+
* The service key for MSGraphClientFactory.
|
|
14
|
+
*/
|
|
15
|
+
static readonly serviceKey: ServiceKey<MSGraphClientFactory>;
|
|
16
|
+
private _serviceScope;
|
|
17
|
+
/**
|
|
18
|
+
* @param serviceScope - Provides services for the MSGraphClient to consume.
|
|
19
|
+
*
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
constructor(serviceScope: ServiceScope);
|
|
23
|
+
/**
|
|
24
|
+
* Returns an instance of the MSGraphClient that communicates with the current tenant's configurable
|
|
25
|
+
* Service Principal. Returns version 1 by default.
|
|
26
|
+
*
|
|
27
|
+
* @internal
|
|
28
|
+
*
|
|
29
|
+
* @remarks
|
|
30
|
+
* This method is deprecated marked as internal for backward compatibility
|
|
31
|
+
*/
|
|
32
|
+
getClient(): Promise<MSGraphClient>;
|
|
33
|
+
/**
|
|
34
|
+
* Returns an instance of version 3 the MSGraphClient V3 that communicates with the current tenant's configurable
|
|
35
|
+
* Service Principal.
|
|
36
|
+
*
|
|
37
|
+
*/
|
|
38
|
+
getClient(version: '3'): Promise<MSGraphClientV3>;
|
|
39
|
+
/**
|
|
40
|
+
* Returns an instance of the MSGraphClient that communicates with the current tenant's configurable Service Pricipal.
|
|
41
|
+
* Allows to specify custom middleware options.
|
|
42
|
+
*
|
|
43
|
+
* @param version - The version of the Graph API to use. 3.
|
|
44
|
+
* @param options - Client options for the Graph API.
|
|
45
|
+
*/
|
|
46
|
+
getClientWithMiddleware(version: '3', options: ClientOptions): Promise<MSGraphClientV3>;
|
|
47
|
+
/**
|
|
48
|
+
* Returns a v3 version of MSGraphClient with the 1P App Principal
|
|
49
|
+
*
|
|
50
|
+
* @internal
|
|
51
|
+
*
|
|
52
|
+
*/
|
|
53
|
+
getClientInternal(version: '3', options?: Options): Promise<MSGraphClientV3>;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=MSGraphClientFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MSGraphClientFactory.d.ts","sourceRoot":"","sources":["../src/MSGraphClientFactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAChF,OAAO,EAAE,UAAU,EAAE,KAAK,YAAY,EAAiB,MAAM,4BAA4B,CAAC;AAE1F,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,eAAe,MAAM,mBAAmB,CAAC;AAIrD;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,oBAAoB;IACvC;;OAEG;IACH,gBAAuB,UAAU,EAAE,UAAU,CAAC,oBAAoB,CAAC,CAC6B;IAEhG,OAAO,CAAC,aAAa,CAAe;IAEpC;;;;OAIG;gBACgB,YAAY,EAAE,YAAY;IAI7C;;;;;;;;OAQG;IACI,SAAS,IAAI,OAAO,CAAC,aAAa,CAAC;IAE1C;;;;OAIG;IACI,SAAS,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,eAAe,CAAC;IAwCxD;;;;;;OAMG;IACI,uBAAuB,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,eAAe,CAAC;IAgB9F;;;;;OAKG;IACI,iBAAiB,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,eAAe,CAAC;CAcpF"}
|
|
@@ -0,0 +1,106 @@
|
|
|
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
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { type ServiceScope } from '@microsoft/sp-core-library';
|
|
2
|
+
import type { ClientOptions, GraphRequest, Options, Client } from '@microsoft/microsoft-graph-client';
|
|
3
|
+
/**
|
|
4
|
+
* MSGraphClient is used to perform REST calls against Microsoft Graph.
|
|
5
|
+
*
|
|
6
|
+
* @remarks The Microsoft Graph JavaScript client library is a lightweight wrapper around the
|
|
7
|
+
* Microsoft Graph API. This class allows developers to start making REST calls to MSGraph without
|
|
8
|
+
* needing to initialize the the MSGraph client library. If a custom configuration is desired,
|
|
9
|
+
* the MSGraphClient api function needs to be provided with that custom configuration for
|
|
10
|
+
* every request.
|
|
11
|
+
*
|
|
12
|
+
* For more information: {@link https://github.com/microsoftgraph/msgraph-sdk-javascript}
|
|
13
|
+
*
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export default class MSGraphClientV3 {
|
|
17
|
+
private static _instance;
|
|
18
|
+
private static _internalInstance;
|
|
19
|
+
private static _graphBaseUrl;
|
|
20
|
+
private _isInternal;
|
|
21
|
+
private _consumerComponentManifest;
|
|
22
|
+
/**
|
|
23
|
+
* @param serviceScope - Provides services for the MSGraphClient to consume.
|
|
24
|
+
*
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
constructor(serviceScope: ServiceScope, options: Options | undefined, clientOptions: ClientOptions | undefined, internalClient?: boolean);
|
|
28
|
+
/**
|
|
29
|
+
* All calls to Microsoft Graph are chained together starting with the api function.
|
|
30
|
+
*
|
|
31
|
+
* @remarks Path supports the following formats:
|
|
32
|
+
* * me
|
|
33
|
+
* * /me
|
|
34
|
+
* * https://graph.microsoft.com/v1.0/me
|
|
35
|
+
* * https://graph.microsoft.com/beta/me
|
|
36
|
+
* * me/events?$filter=startswith(subject, 'ship')
|
|
37
|
+
*
|
|
38
|
+
* The authProvider and baseUrl option should not be used, as they have already been
|
|
39
|
+
* provided by the framework. See the official documentation here:
|
|
40
|
+
* https://github.com/microsoftgraph/msgraph-sdk-javascript
|
|
41
|
+
*
|
|
42
|
+
* @param path - The path for the request to MSGraph.
|
|
43
|
+
*/
|
|
44
|
+
api(path: string): GraphRequest;
|
|
45
|
+
/**
|
|
46
|
+
* Gets the instance of the instantiated Client object from Microsoft Graph SDK.
|
|
47
|
+
*/
|
|
48
|
+
get client(): Client;
|
|
49
|
+
private _createGraphClientInstance;
|
|
50
|
+
private _createGraphClientInstanceWithMiddleware;
|
|
51
|
+
private _createInternalGraphClientInstance;
|
|
52
|
+
private _createClientInstance;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=MSGraphClientV3.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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;AAgB3C;;;;;;;;;;;;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;IAE7E;;;;OAIG;gBAED,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,OAAO,GAAG,SAAS,EAC5B,aAAa,EAAE,aAAa,GAAG,SAAS,EACxC,cAAc,CAAC,EAAE,OAAO;IAsC1B;;;;;;;;;;;;;;;OAeG;IACI,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY;IAQtC;;OAEG;IACH,IAAW,MAAM,IAAI,MAAM,CAK1B;IAED,OAAO,CAAC,0BAA0B;IAqBlC,OAAO,CAAC,wCAAwC;IAmBhD,OAAO,CAAC,kCAAkC;IAoB1C,OAAO,CAAC,qBAAqB;CAyE9B"}
|
|
@@ -0,0 +1,194 @@
|
|
|
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 } from '@microsoft/sp-http-base';
|
|
6
|
+
import { isCustomHostsKSActivated, isPassSdkVersionKSActivated } 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 (internalClient) {
|
|
41
|
+
_this._isInternal = true;
|
|
42
|
+
if (!MSGraphClientV3._internalInstance) {
|
|
43
|
+
MSGraphClientV3._internalInstance = _this._createInternalGraphClientInstance(_AadTokenProviders.configurable, options);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
else if (!MSGraphClientV3._instance) {
|
|
47
|
+
if (clientOptions !== undefined) {
|
|
48
|
+
MSGraphClientV3._instance = _this._createGraphClientInstanceWithMiddleware(_AadTokenProviders.configurable, clientOptions);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
MSGraphClientV3._instance = _this._createGraphClientInstance(_AadTokenProviders.configurable, options);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* All calls to Microsoft Graph are chained together starting with the api function.
|
|
58
|
+
*
|
|
59
|
+
* @remarks Path supports the following formats:
|
|
60
|
+
* * me
|
|
61
|
+
* * /me
|
|
62
|
+
* * https://graph.microsoft.com/v1.0/me
|
|
63
|
+
* * https://graph.microsoft.com/beta/me
|
|
64
|
+
* * me/events?$filter=startswith(subject, 'ship')
|
|
65
|
+
*
|
|
66
|
+
* The authProvider and baseUrl option should not be used, as they have already been
|
|
67
|
+
* provided by the framework. See the official documentation here:
|
|
68
|
+
* https://github.com/microsoftgraph/msgraph-sdk-javascript
|
|
69
|
+
*
|
|
70
|
+
* @param path - The path for the request to MSGraph.
|
|
71
|
+
*/
|
|
72
|
+
MSGraphClientV3.prototype.api = function (path) {
|
|
73
|
+
Validate.isNonemptyString(path, 'path');
|
|
74
|
+
if (this._isInternal) {
|
|
75
|
+
return MSGraphClientV3._internalInstance.api(path);
|
|
76
|
+
}
|
|
77
|
+
return MSGraphClientV3._instance.api(path);
|
|
78
|
+
};
|
|
79
|
+
Object.defineProperty(MSGraphClientV3.prototype, "client", {
|
|
80
|
+
/**
|
|
81
|
+
* Gets the instance of the instantiated Client object from Microsoft Graph SDK.
|
|
82
|
+
*/
|
|
83
|
+
get: function () {
|
|
84
|
+
if (this._isInternal) {
|
|
85
|
+
return MSGraphClientV3._internalInstance;
|
|
86
|
+
}
|
|
87
|
+
return MSGraphClientV3._instance;
|
|
88
|
+
},
|
|
89
|
+
enumerable: false,
|
|
90
|
+
configurable: true
|
|
91
|
+
});
|
|
92
|
+
MSGraphClientV3.prototype._createGraphClientInstance = function (tokenProvider, options) {
|
|
93
|
+
var qosMonitor = new _QosMonitor('MSGraphClientV3.CreateGraphClientInstance');
|
|
94
|
+
var graphClient;
|
|
95
|
+
try {
|
|
96
|
+
graphClient = this._createClientInstance(__assign(__assign({}, options), { authProvider: undefined }), tokenProvider, false);
|
|
97
|
+
}
|
|
98
|
+
catch (e) {
|
|
99
|
+
qosMonitor.writeUnexpectedFailure(e.message, e);
|
|
100
|
+
throw e;
|
|
101
|
+
}
|
|
102
|
+
return graphClient;
|
|
103
|
+
};
|
|
104
|
+
MSGraphClientV3.prototype._createGraphClientInstanceWithMiddleware = function (tokenProvider, options) {
|
|
105
|
+
var qosMonitor = new _QosMonitor('MSGraphClientV3.CreateGraphClientInstanceWithMiddleware');
|
|
106
|
+
var graphClient;
|
|
107
|
+
try {
|
|
108
|
+
graphClient = this._createClientInstance(options, tokenProvider, false);
|
|
109
|
+
qosMonitor.writeSuccess();
|
|
110
|
+
return graphClient;
|
|
111
|
+
}
|
|
112
|
+
catch (e) {
|
|
113
|
+
qosMonitor.writeUnexpectedFailure(e.message, e);
|
|
114
|
+
throw e;
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
MSGraphClientV3.prototype._createInternalGraphClientInstance = function (tokenProvider, options) {
|
|
118
|
+
var qosMonitor = new _QosMonitor('MSGraphClientV3.CreateInternalGraphClientInstance');
|
|
119
|
+
var graphClient;
|
|
120
|
+
try {
|
|
121
|
+
graphClient = this._createClientInstance(__assign(__assign({}, options), { authProvider: undefined }), tokenProvider, true);
|
|
122
|
+
}
|
|
123
|
+
catch (e) {
|
|
124
|
+
qosMonitor.writeUnexpectedFailure(e.message, e);
|
|
125
|
+
throw e;
|
|
126
|
+
}
|
|
127
|
+
return graphClient;
|
|
128
|
+
};
|
|
129
|
+
MSGraphClientV3.prototype._createClientInstance = function (options, tokenProvider, isInternal) {
|
|
130
|
+
var clientOptions = options || {};
|
|
131
|
+
clientOptions.baseUrl = MSGraphClientV3._graphBaseUrl;
|
|
132
|
+
var middlewareChain;
|
|
133
|
+
if (!clientOptions.middleware) {
|
|
134
|
+
// creating default chain
|
|
135
|
+
middlewareChain = MiddlewareFactory.getDefaultMiddlewareChain(new MSGraphAuthenticationProvider(tokenProvider, MSGraphClientV3._graphBaseUrl, isInternal));
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
// a developer has provided middleware(s)
|
|
139
|
+
var authMiddleware = new AuthenticationHandler(new MSGraphAuthenticationProvider(tokenProvider, MSGraphClientV3._graphBaseUrl, isInternal));
|
|
140
|
+
middlewareChain = [authMiddleware];
|
|
141
|
+
if (Array.isArray(clientOptions.middleware)) {
|
|
142
|
+
middlewareChain.push.apply(middlewareChain, clientOptions.middleware);
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
middlewareChain.push(clientOptions.middleware);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if (!isPassSdkVersionKSActivated() && this._consumerComponentManifest) {
|
|
149
|
+
if (!clientOptions.fetchOptions) {
|
|
150
|
+
clientOptions.fetchOptions = {};
|
|
151
|
+
}
|
|
152
|
+
if (!clientOptions.fetchOptions.headers) {
|
|
153
|
+
clientOptions.fetchOptions.headers = {};
|
|
154
|
+
}
|
|
155
|
+
var sdkVersionValue = "SPFx/".concat(this._consumerComponentManifest.alias, "/").concat(this._consumerComponentManifest.id, "/Is3PRequest:").concat(this._consumerComponentManifest.isInternal ? '0' : '1');
|
|
156
|
+
var headers = clientOptions.fetchOptions.headers;
|
|
157
|
+
if (Array.isArray(headers)) {
|
|
158
|
+
var sdkVersionHeaderIndex = headers.findIndex(function (header) { return header[0] === 'SdkVersion'; });
|
|
159
|
+
if (sdkVersionHeaderIndex === -1) {
|
|
160
|
+
headers.push(['SdkVersion', sdkVersionValue]);
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
headers[sdkVersionHeaderIndex][1] += ", ".concat(sdkVersionValue);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
else if (headers instanceof Headers) {
|
|
167
|
+
headers.has('SdkVersion')
|
|
168
|
+
? headers.set('SdkVersion', "".concat(headers.get('SdkVersion'), ", ").concat(sdkVersionValue))
|
|
169
|
+
: headers.set('SdkVersion', sdkVersionValue);
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
headers.SdkVersion = headers.SdkVersions
|
|
173
|
+
? "".concat(headers.SdkVersion, ", ").concat(sdkVersionValue)
|
|
174
|
+
: sdkVersionValue;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
// we can add more middleware to the end of the chain here
|
|
178
|
+
clientOptions.middleware = middlewareChain;
|
|
179
|
+
if (!isCustomHostsKSActivated()) {
|
|
180
|
+
try {
|
|
181
|
+
var url = new URL(MSGraphClientV3._graphBaseUrl);
|
|
182
|
+
clientOptions.customHosts = new Set([url.host]);
|
|
183
|
+
}
|
|
184
|
+
catch (e) {
|
|
185
|
+
var qosMonitor = new _QosMonitor('MSGraphClientV3.CustomHostsAdditionsFailed');
|
|
186
|
+
qosMonitor.writeUnexpectedFailure(e.message, e);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return _InternalGraphClient.initWithMiddleware(clientOptions);
|
|
190
|
+
};
|
|
191
|
+
return MSGraphClientV3;
|
|
192
|
+
}());
|
|
193
|
+
export default MSGraphClientV3;
|
|
194
|
+
//# sourceMappingURL=MSGraphClientV3.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// This file was generated by a tool. Modifying it will produce unexpected behavior
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export interface ISPHttpMsGraphStrings {
|
|
7
|
+
/**
|
|
8
|
+
* [Tag:ODSP-SPPPLAT-SPHttp] Message to show when the MSGraphClient cannot be constructed. MSGraphClient is a javascript SDK for interacting with Microsoft Graph's REST APIs.
|
|
9
|
+
*/
|
|
10
|
+
'graphClientInitializationError': string;
|
|
11
|
+
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
declare const strings: ISPHttpMsGraphStrings;
|
|
18
|
+
|
|
19
|
+
export default strings;
|