@microsoft/sp-http-msgraph 1.16.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.
@@ -0,0 +1,125 @@
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 ms_graph_v3_bundle_1 = require("@ms/ms-graph-v3-bundle");
7
+ var sp_http_base_1 = require("@microsoft/sp-http-base");
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) {
28
+ var _this = this;
29
+ serviceScope.whenFinished(function () {
30
+ MSGraphClientV3._graphBaseUrl = serviceScope
31
+ .consume(sp_http_base_1._GraphHttpClientContext.serviceKey)
32
+ .getGraphEndpointUrl();
33
+ if (!MSGraphClientV3._instance) {
34
+ if (clientOptions !== undefined) {
35
+ MSGraphClientV3._instance = _this._createGraphClientInstanceWithMiddleware(sp_http_base_1._AadTokenProviders.configurable, clientOptions);
36
+ }
37
+ else {
38
+ MSGraphClientV3._instance = _this._createGraphClientInstance(sp_http_base_1._AadTokenProviders.configurable, options);
39
+ }
40
+ }
41
+ });
42
+ }
43
+ /**
44
+ * All calls to Microsoft Graph are chained together starting with the api function.
45
+ *
46
+ * @remarks Path supports the following formats:
47
+ * * me
48
+ * * /me
49
+ * * https://graph.microsoft.com/v1.0/me
50
+ * * https://graph.microsoft.com/beta/me
51
+ * * me/events?$filter=startswith(subject, 'ship')
52
+ *
53
+ * The authProvider and baseUrl option should not be used, as they have already been
54
+ * provided by the framework. See the official documentation here:
55
+ * https://github.com/microsoftgraph/msgraph-sdk-javascript
56
+ *
57
+ * @param path - The path for the request to MSGraph.
58
+ */
59
+ MSGraphClientV3.prototype.api = function (path) {
60
+ sp_core_library_1.Validate.isNonemptyString(path, 'path');
61
+ return MSGraphClientV3._instance.api(path);
62
+ };
63
+ Object.defineProperty(MSGraphClientV3.prototype, "client", {
64
+ /**
65
+ * Gets the instance of the instantiated Client object from Microsoft Graph SDK.
66
+ */
67
+ get: function () {
68
+ return MSGraphClientV3._instance;
69
+ },
70
+ enumerable: false,
71
+ configurable: true
72
+ });
73
+ MSGraphClientV3.prototype._createGraphClientInstance = function (tokenProvider, options) {
74
+ var _this = this;
75
+ var qosMonitor = new sp_diagnostics_1._QosMonitor('MSGraphClientV3.CreateGraphClientInstance');
76
+ var graphClient = ms_graph_v3_bundle_1.Client.init(tslib_1.__assign({ authProvider: function (done) {
77
+ _this._getOAuthToken(tokenProvider)
78
+ .then(function (token) {
79
+ done(undefined /** error object */, token);
80
+ qosMonitor.writeSuccess();
81
+ })
82
+ .catch(function (e) {
83
+ // The functions will return a rejected promise if it fails to get an OAuth2Token.
84
+ done(e, '');
85
+ qosMonitor.writeExpectedFailure(e.message);
86
+ });
87
+ }, baseUrl: MSGraphClientV3._graphBaseUrl }, options // with this, the user can override the baseUrl and authProvider too
88
+ ));
89
+ return graphClient;
90
+ };
91
+ MSGraphClientV3.prototype._createGraphClientInstanceWithMiddleware = function (tokenProvider, options) {
92
+ var _this = this;
93
+ var qosMonitor = new sp_diagnostics_1._QosMonitor('MSGraphClientV3.CreateGraphClientInstanceWithMiddleware');
94
+ try {
95
+ var graphClient = ms_graph_v3_bundle_1.Client.initWithMiddleware(tslib_1.__assign({ authProvider: {
96
+ getAccessToken: function (authenticationProviderOptions) {
97
+ return _this._getOAuthToken(tokenProvider);
98
+ }
99
+ }, baseUrl: MSGraphClientV3._graphBaseUrl }, options // with this, the user can override the baseUrl and authProvider too
100
+ ));
101
+ qosMonitor.writeSuccess();
102
+ return graphClient;
103
+ }
104
+ catch (e) {
105
+ qosMonitor.writeUnexpectedFailure('CreateGraphClientInstanceWithMiddleware', e);
106
+ throw e;
107
+ }
108
+ };
109
+ MSGraphClientV3.prototype._getOAuthToken = function (tokenProvider) {
110
+ var qosMonitor = new sp_diagnostics_1._QosMonitor('MSGraphClient.FetchGraphToken');
111
+ return tokenProvider
112
+ .getToken(MSGraphClientV3._graphBaseUrl)
113
+ .then(function (response) {
114
+ qosMonitor.writeSuccess();
115
+ return response;
116
+ })
117
+ .catch(function (error) {
118
+ qosMonitor.writeUnexpectedFailure('FetchGraphToken', error);
119
+ throw error;
120
+ });
121
+ };
122
+ return MSGraphClientV3;
123
+ }());
124
+ exports.default = MSGraphClientV3;
125
+ //# sourceMappingURL=MSGraphClientV3.js.map
@@ -0,0 +1,11 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <root>
3
+ <data name="$FILE_ID" xml:space="preserve">
4
+ <value>d825b9d7-8b85-47f7-a88c-1d4c32dd9e99</value>
5
+ <comment>{locked} This is the file ID for this localization file. This string value should not be used or translated.</comment>
6
+ </data>
7
+ <data name="graphClientInitializationError" xml:space="preserve">
8
+ <value>Sorry, we couldn't make a connection to Microsoft Graph.</value>
9
+ <comment>[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. </comment>
10
+ </data>
11
+ </root>
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ /**
3
+ * Microsoft Graph communication layer for the SharePoint Framework
4
+ *
5
+ * @remarks
6
+ * This package defines the base communication layer between Microsoft Graph and
7
+ * the SharePoint Framework.
8
+ *
9
+ * @packagedocumentation
10
+ */
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.MSGraphClientFactory = exports.MSGraphClient = void 0;
16
+ var MSGraphClient_1 = require("./MSGraphClient");
17
+ Object.defineProperty(exports, "MSGraphClient", { enumerable: true, get: function () { return __importDefault(MSGraphClient_1).default; } });
18
+ var MSGraphClientFactory_1 = require("./MSGraphClientFactory");
19
+ Object.defineProperty(exports, "MSGraphClientFactory", { enumerable: true, get: function () { return __importDefault(MSGraphClientFactory_1).default; } });
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,14 @@
1
+ {
2
+ "$schema": "https://developer.microsoft.com/json-schemas/spfx/client-side-component-manifest.schema.json",
3
+
4
+ "manifestVersion": 2,
5
+
6
+ "id": "aec2bbfd-a968-4d5b-a279-12e570f378e6",
7
+ "alias": "@microsoft/sp-http-msgraph",
8
+ "componentType": "Library",
9
+
10
+ // The "*" instructs the tools take the version from package.json when generating the output manifest.
11
+ // For a first party web part that is deployed with sp-client, this version is not very meaningful.
12
+ // We recommend to put "1.0.0" in your package.json and not worry about incrementing it.
13
+ "version": "*"
14
+ }
package/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "@microsoft/sp-http-msgraph",
3
+ "version": "1.16.0-beta.2",
4
+ "description": "Microsoft Graph communication layer for the SharePoint Framework",
5
+ "license": "https://aka.ms/spfx/license",
6
+ "homepage": "http://aka.ms/spfx",
7
+ "main": "lib-commonjs/index.js",
8
+ "module": "lib/index.js",
9
+ "typings": "dist/index-internal.d.ts",
10
+ "tsdoc": {
11
+ "tsdocFlavor": "AEDoc"
12
+ },
13
+ "scripts": {},
14
+ "dependencies": {
15
+ "@microsoft/microsoft-graph-clientv1": "npm:@microsoft/microsoft-graph-client@1.7.2-spfx",
16
+ "@microsoft/sp-core-library": "1.16.0-beta.2",
17
+ "@microsoft/sp-diagnostics": "1.16.0-beta.2",
18
+ "@microsoft/sp-http-base": "1.16.0-beta.2",
19
+ "@microsoft/sp-loader": "1.16.0-beta.2",
20
+ "tslib": "2.3.1"
21
+ }
22
+ }