@microsoft/sp-component-base 1.18.2 → 1.19.0-rc.0

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 (26) hide show
  1. package/dist/467dc675-7cc5-4709-8aac-78e3b71bd2f6.manifest.json +153 -153
  2. package/dist/chunk.legacy-third-party-fabric-core-localfont_none_dd28360c57e794beefd1.js +2 -0
  3. package/dist/chunk.teams-apps-client_none_5be8a0b54d65dad97062.js +2 -0
  4. package/dist/index-internal-beta.d.ts +8 -0
  5. package/dist/index-internal-public.d.ts +8 -0
  6. package/dist/index-internal.d.ts +8 -0
  7. package/dist/sp-component-base_default_8d09a1af32c0979f00b2.js +2 -0
  8. package/dist/sp-component-base_en-us_f7855abf96d9880ed89e.js +2 -0
  9. package/dist/sp-component-base_qps-ploc_4b0d8b3bf0b7b5cf24d5.js +2 -0
  10. package/dist/sp-component-base_qps-ploca_729c8f356007cd0d1870.js +2 -0
  11. package/dist/tsdoc-metadata.json +1 -1
  12. package/lib-commonjs/PropertyMetadataProcessor.js +31 -6
  13. package/lib-commonjs/chunks/legacy-third-party-fabric-core/fabric-core-sass/Fabric.LocalFont.global.scss.css +421 -421
  14. package/lib-commonjs/chunks/legacy-third-party-fabric-core/fabric-core-sass/Fabric.LocalFontKillSwitchActivated.scss.css +421 -421
  15. package/lib-commonjs/chunks/legacy-third-party-fabric-core/iconDefinitions.css +1 -1
  16. package/lib-commonjs/common/Flights.js +15 -0
  17. package/lib-commonjs/index.js +3 -1
  18. package/lib-commonjs/teams/DeferredTeamsAppsClient.js +63 -0
  19. package/lib-commonjs/teams/ITeamsAppCatalog.js +3 -0
  20. package/lib-commonjs/teams/TeamsAppsClient.js +443 -0
  21. package/package.json +13 -12
  22. package/dist/chunk.legacy-third-party-fabric-core-localfont_none_9ce81372d90197900b3d.js +0 -1
  23. package/dist/sp-component-base_default_5a92659f8b74b60f46e7.js +0 -1
  24. package/dist/sp-component-base_en-us_5a92659f8b74b60f46e7.js +0 -1
  25. package/dist/sp-component-base_qps-ploc_5a92659f8b74b60f46e7.js +0 -1
  26. package/dist/sp-component-base_qps-ploca_5a92659f8b74b60f46e7.js +0 -1
@@ -1,6 +1,6 @@
1
1
  @font-face {
2
2
  font-family: FabricMDL2Icons;
3
- src: url("https://res-1.cdn.office.net/files/fabric-cdn-prod_20220825.001/assets/icons/fabricmdl2icons-2.23.woff2") format("woff2"), url("https://res-1.cdn.office.net/files/fabric-cdn-prod_20220825.001/assets/icons/fabricmdl2icons-2.23.woff") format("woff"), url("https://res-1.cdn.office.net/files/fabric-cdn-prod_20220825.001/assets/icons/fabricmdl2icons-2.23.ttf") format("truetype");
3
+ src: url("https://res-1.cdn.office.net/files/fabric-cdn-prod_20231211.002/assets/icons/fabricmdl2icons-2.23.woff2") format("woff2"), url("https://res-1.cdn.office.net/files/fabric-cdn-prod_20231211.002/assets/icons/fabricmdl2icons-2.23.woff") format("woff"), url("https://res-1.cdn.office.net/files/fabric-cdn-prod_20231211.002/assets/icons/fabricmdl2icons-2.23.ttf") format("truetype");
4
4
  font-weight: normal;
5
5
  font-style: normal;
6
6
  }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isServerPropertiesSanitizedEnabled = exports.isBotAcesFromTeamsEnabled = void 0;
4
+ var sp_core_library_1 = require("@microsoft/sp-core-library");
5
+ // cross-project flight
6
+ function isBotAcesFromTeamsEnabled() {
7
+ return sp_core_library_1._SPFlight.isEnabled(60693 /* APEXBotAceFromTeamsClient */);
8
+ }
9
+ exports.isBotAcesFromTeamsEnabled = isBotAcesFromTeamsEnabled;
10
+ // cross-project flight
11
+ function isServerPropertiesSanitizedEnabled() {
12
+ return sp_core_library_1._SPFlight.isEnabled(61389 /* APEXServerPropertiesSanitizedEnabled */);
13
+ }
14
+ exports.isServerPropertiesSanitizedEnabled = isServerPropertiesSanitizedEnabled;
15
+ //# sourceMappingURL=Flights.js.map
@@ -14,7 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports._CacheMissReason = exports._WebPartLoadDataCollector = exports._ensureIsolatedDomainUrl = exports._ShimmerFactory = exports.ThemeProvider = exports.ThemeChangedEventArgs = exports.ServerProcessedDataType = exports._PropertyMetadataProcessor = exports._LegacyThirdPartyFabricCoreLoader = exports.DynamicProperty = exports.DynamicDataSourceManager = exports.DynamicDataProvider = exports.BaseComponentContext = exports.BaseComponent = void 0;
17
+ exports._DeferredTeamsAppsClient = exports._CacheMissReason = exports._WebPartLoadDataCollector = exports._ensureIsolatedDomainUrl = exports._ShimmerFactory = exports.ThemeProvider = exports.ThemeChangedEventArgs = exports.ServerProcessedDataType = exports._PropertyMetadataProcessor = exports._LegacyThirdPartyFabricCoreLoader = exports.DynamicProperty = exports.DynamicDataSourceManager = exports.DynamicDataProvider = exports.BaseComponentContext = exports.BaseComponent = void 0;
18
18
  var BaseComponent_1 = require("./BaseComponent");
19
19
  Object.defineProperty(exports, "BaseComponent", { enumerable: true, get: function () { return __importDefault(BaseComponent_1).default; } });
20
20
  var BaseComponentContext_1 = require("./BaseComponentContext");
@@ -43,4 +43,6 @@ var WebPartLoadDataCollector_1 = require("./dataCollector/WebPartLoadDataCollect
43
43
  Object.defineProperty(exports, "_WebPartLoadDataCollector", { enumerable: true, get: function () { return WebPartLoadDataCollector_1.WebPartLoadDataCollector; } });
44
44
  var IWebPartLoadData_1 = require("./dataCollector/IWebPartLoadData");
45
45
  Object.defineProperty(exports, "_CacheMissReason", { enumerable: true, get: function () { return IWebPartLoadData_1.CacheMissReason; } });
46
+ var DeferredTeamsAppsClient_1 = require("./teams/DeferredTeamsAppsClient");
47
+ Object.defineProperty(exports, "_DeferredTeamsAppsClient", { enumerable: true, get: function () { return DeferredTeamsAppsClient_1.DeferredTeamsAppsClient; } });
46
48
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.DeferredTeamsAppsClient = void 0;
27
+ var sp_core_library_1 = require("@microsoft/sp-core-library");
28
+ var sp_diagnostics_1 = require("@microsoft/sp-diagnostics");
29
+ /**
30
+ * @internal
31
+ */
32
+ var DeferredTeamsAppsClient = /** @class */ (function () {
33
+ function DeferredTeamsAppsClient(serviceScope) {
34
+ this._serviceScope = serviceScope;
35
+ }
36
+ DeferredTeamsAppsClient.prototype.getClient = function () {
37
+ var _this = this;
38
+ if (this._teamsAppsClient) {
39
+ return Promise.resolve(this._teamsAppsClient);
40
+ }
41
+ if (!this._teamsAppsClientPromise) {
42
+ var loadMonitor_1 = new sp_diagnostics_1._QosMonitor('DeferredTeamsAppsClient.LoadTeamsAppClient');
43
+ this._teamsAppsClientPromise = Promise.resolve().then(function () { return __importStar(require(/* webpackChunkName: 'teams-apps-client' */ './TeamsAppsClient')); }).then(function (_a) {
44
+ var TeamsAppsClient = _a.TeamsAppsClient;
45
+ _this._teamsAppsClient = new TeamsAppsClient(_this._serviceScope);
46
+ loadMonitor_1.writeSuccess();
47
+ return _this._teamsAppsClient;
48
+ })
49
+ .catch(function (error) {
50
+ loadMonitor_1.writeUnexpectedFailure(undefined, error);
51
+ throw error;
52
+ });
53
+ }
54
+ return this._teamsAppsClientPromise;
55
+ };
56
+ /**
57
+ * The service key for DeferredTeamsAppsClient.
58
+ */
59
+ DeferredTeamsAppsClient.serviceKey = sp_core_library_1.ServiceKey.create('sp-teams-apps-client', DeferredTeamsAppsClient);
60
+ return DeferredTeamsAppsClient;
61
+ }());
62
+ exports.DeferredTeamsAppsClient = DeferredTeamsAppsClient;
63
+ //# sourceMappingURL=DeferredTeamsAppsClient.js.map
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ITeamsAppCatalog.js.map
@@ -0,0 +1,443 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TeamsAppsClient = void 0;
4
+ var sp_diagnostics_1 = require("@microsoft/sp-diagnostics");
5
+ var sp_http_1 = require("@microsoft/sp-http");
6
+ var sp_page_context_1 = require("@microsoft/sp-page-context");
7
+ var Flights_1 = require("../common/Flights");
8
+ var sp_lodash_subset_1 = require("@microsoft/sp-lodash-subset");
9
+ // base teams apps endpoint
10
+ var MS_GRAPH_TEAMS_APPS_ENDPOINT = '/appCatalogs/teamsApps';
11
+ // QSP to fetch all teams apps with dashboard cards
12
+ var MS_GRAPH_FETCH_TEAMS_APPS_QSP = "$expand=appDefinitions($expand=outlineIcon,colorIcon,dashboardCards)&$filter=appDefinitions/any(a:a/dashboardCards/$count ne 0)";
13
+ // QSP to check permissions for the list of app ids
14
+ var MS_GRAPH_CHECK_PERMISSIONS_QSP = "$expand=appDefinitions($expand=dashboardCards)&$filter=appDefinitions/any(a:a/dashboardCards/$count ne 0) and id in ('{appIds}')";
15
+ var MS_GRAPH_API_VERSION = 'beta';
16
+ // the number of app ids we can process without batching the request to avoid the URL length limit
17
+ var MAX_IDS_WITHOUT_BATCHING = 30;
18
+ var MAX_REQUESTS_PER_BATCH = 10;
19
+ var MANIFEST_VERSION = 2;
20
+ var ADVANCED_TOOLBOX_GROUP_ID = '5c03119e-3074-46fd-976b-c60198311f70';
21
+ /**
22
+ * The client for the Teams Apps sync.
23
+ *
24
+ * @internal
25
+ */
26
+ var TeamsAppsClient = /** @class */ (function () {
27
+ function TeamsAppsClient(serviceScope) {
28
+ /**
29
+ * Map[teamsAppId, Promise[Set[teamsAppId]]]
30
+ *
31
+ * We store a map where the same promise can be used for multiple entries.
32
+ * In that case we can avoid multiple requests to the API for the same teamsAppId as well as avoid race conditions and allow to make extra requests if needed.
33
+ */
34
+ this._appComponentsPermissionsPromises = new Map();
35
+ this._serviceScope = serviceScope;
36
+ }
37
+ /**
38
+ * Gets the list of Teams App components from Teams App Catalog.
39
+ * @returns Promise that resolves to the list of Teams App components.
40
+ */
41
+ TeamsAppsClient.prototype.getTeamsAppComponentManifests = function () {
42
+ var _this = this;
43
+ if (!TeamsAppsClient._getTeamsAppComponentManifestsPromise) {
44
+ if (!(0, Flights_1.isBotAcesFromTeamsEnabled)()) {
45
+ TeamsAppsClient._getTeamsAppComponentManifestsPromise = Promise.resolve([]);
46
+ }
47
+ else {
48
+ var monitor_1 = new sp_diagnostics_1._QosMonitor('TeamsAppsClient.FetchTeamsApp');
49
+ TeamsAppsClient._getTeamsAppComponentManifestsPromise = this._msGraphClient
50
+ .then(function (client) {
51
+ return client
52
+ .api("".concat(MS_GRAPH_TEAMS_APPS_ENDPOINT, "?").concat(MS_GRAPH_FETCH_TEAMS_APPS_QSP))
53
+ .version(MS_GRAPH_API_VERSION)
54
+ .get();
55
+ })
56
+ .then(function (response) {
57
+ var manifestsPromises = response.value.map(function (item) {
58
+ return _this._teamsAppCatalogItemToAceManifests(item);
59
+ });
60
+ return Promise.all(manifestsPromises).then(function (manifests) {
61
+ var flatManifests = [];
62
+ manifests.forEach(function (item) {
63
+ flatManifests.push.apply(flatManifests, item);
64
+ });
65
+ monitor_1.writeSuccess();
66
+ return flatManifests;
67
+ });
68
+ })
69
+ .catch(function (error) {
70
+ monitor_1.writeUnexpectedFailure(undefined, error);
71
+ // removing reference to the promise to allow retry
72
+ TeamsAppsClient._getTeamsAppComponentManifestsPromise = undefined;
73
+ return [];
74
+ });
75
+ }
76
+ }
77
+ return TeamsAppsClient._getTeamsAppComponentManifestsPromise;
78
+ };
79
+ /**
80
+ * Syncs the Teams App component into SharePoint App Catalog.
81
+ */
82
+ TeamsAppsClient.prototype.syncComponent = function (teamsAppComponentManifest) {
83
+ var _this = this;
84
+ var _a;
85
+ var manifest = teamsAppComponentManifest;
86
+ if (!(0, Flights_1.isBotAcesFromTeamsEnabled)() || !manifest.isPendingTeamsAppSync) {
87
+ return Promise.resolve(teamsAppComponentManifest);
88
+ }
89
+ var monitor = new sp_diagnostics_1._QosMonitor('TeamsAppsClient.SyncComponent');
90
+ if (!((_a = teamsAppComponentManifest.properties) === null || _a === void 0 ? void 0 : _a.teamsAppComponent)) {
91
+ monitor.writeExpectedFailure('TeamsAppComponentMissing');
92
+ return new Promise(function () {
93
+ throw new Error('Teams App component manifest is missing teamsAppComponent property');
94
+ });
95
+ }
96
+ var spHttpClient = this._serviceScope.consume(sp_http_1.SPHttpClient.serviceKey);
97
+ var pageContext = this._serviceScope.consume(sp_page_context_1.PageContext.serviceKey);
98
+ var baseRequestUrl = pageContext.web.absoluteUrl;
99
+ var monitorFailureTagNameSuffix = undefined;
100
+ var ensureAppCatalogPromise = TeamsAppsClient._ensureAppCatalogPromise;
101
+ if (!TeamsAppsClient._ensureAppCatalogPromise) {
102
+ // first step is to ensure app catalog
103
+ var ensureAppCatalogRequestUrl = "".concat(baseRequestUrl, "/_api/web/EnsureTenantAppCatalog(callerId='TeamsAppsClient')");
104
+ ensureAppCatalogPromise = TeamsAppsClient._ensureAppCatalogPromise = spHttpClient
105
+ .post(ensureAppCatalogRequestUrl, sp_http_1.SPHttpClient.configurations.v1, {})
106
+ .then(function (response) {
107
+ return response.json();
108
+ })
109
+ .then(function (response) {
110
+ if (response.error) {
111
+ throw new Error(response.error.message);
112
+ }
113
+ })
114
+ .catch(function (error) {
115
+ // app catalog error
116
+ monitorFailureTagNameSuffix = 'EnsureAppCatalogFailed';
117
+ // we want to retry if needed
118
+ TeamsAppsClient._ensureAppCatalogPromise = undefined;
119
+ throw error;
120
+ });
121
+ }
122
+ return ensureAppCatalogPromise
123
+ .then(function () {
124
+ var syncRequestUrl = "".concat(baseRequestUrl, "/_api/web/SyncTeamsComponent");
125
+ var teamsAppComponent = teamsAppComponentManifest.properties.teamsAppComponent;
126
+ return spHttpClient
127
+ .post(syncRequestUrl, sp_http_1.SPHttpClient.configurations.v1, {
128
+ body: JSON.stringify({
129
+ teamsComponent: teamsAppComponent
130
+ })
131
+ })
132
+ .catch(function (error) {
133
+ // sync error
134
+ monitorFailureTagNameSuffix = 'SyncComponentFailed';
135
+ throw error;
136
+ });
137
+ })
138
+ .then(function (response) {
139
+ return response.json();
140
+ })
141
+ .then(function (syncedManifest) {
142
+ if (syncedManifest.error) {
143
+ monitorFailureTagNameSuffix = 'SyncComponentFailed';
144
+ throw new Error(syncedManifest.error.message);
145
+ }
146
+ var manifestResponse = syncedManifest;
147
+ var parsedManifest = JSON.parse(manifestResponse.Manifest);
148
+ if (manifestResponse.ManifestActivatedTime) {
149
+ parsedManifest.manifestActivatedTime = manifestResponse.ManifestActivatedTime;
150
+ }
151
+ monitor.writeSuccess();
152
+ var appId = teamsAppComponentManifest.properties.teamsAppComponent.appId;
153
+ // we know for sure the component is allowed
154
+ _this._appComponentsPermissionsPromises.set(appId, Promise.resolve(new Set([appId])));
155
+ return parsedManifest;
156
+ })
157
+ .catch(function (error) {
158
+ monitor.writeUnexpectedFailure(monitorFailureTagNameSuffix, error);
159
+ throw error;
160
+ });
161
+ };
162
+ /**
163
+ * Requests permissions for the Teams App components (apps) for the current user.
164
+ */
165
+ TeamsAppsClient.prototype.requestPermissions = function (teamsAppComponentIds) {
166
+ if (!(0, Flights_1.isBotAcesFromTeamsEnabled)() || !teamsAppComponentIds.length) {
167
+ return Promise.resolve();
168
+ }
169
+ return this._requestAppsPermissions(teamsAppComponentIds).then(function () { });
170
+ };
171
+ /**
172
+ * Checks if the component is enabled for the current user based on requested Teams permissions.
173
+ */
174
+ TeamsAppsClient.prototype.isComponentEnabled = function (teamsAppId) {
175
+ if (!(0, Flights_1.isBotAcesFromTeamsEnabled)()) {
176
+ return Promise.resolve(true);
177
+ }
178
+ if (this._appComponentsPermissionsPromises.has(teamsAppId)) {
179
+ return this._appComponentsPermissionsPromises.get(teamsAppId).then(function (allowedApps) {
180
+ return allowedApps.has(teamsAppId) || false;
181
+ });
182
+ }
183
+ else {
184
+ return this._requestAppsPermissions([{ appId: teamsAppId, componentId: '' }]).then(function (allowedComponents) {
185
+ return allowedComponents.has(teamsAppId) || false;
186
+ });
187
+ }
188
+ };
189
+ TeamsAppsClient.prototype._requestAppsPermissions = function (teamsAppComponentIds) {
190
+ var _this = this;
191
+ // getting app ids for which we don't have a promise yet
192
+ var uniqueAppIds = (0, sp_lodash_subset_1.uniq)(teamsAppComponentIds.map(function (item) { return item.appId; })).filter(function (appId) { return !_this._appComponentsPermissionsPromises.has(appId); });
193
+ var requestPermissionsPromise;
194
+ if (uniqueAppIds.length > MAX_IDS_WITHOUT_BATCHING) {
195
+ requestPermissionsPromise = this._requestAppsPermissionsBatched(uniqueAppIds);
196
+ }
197
+ if (!requestPermissionsPromise) {
198
+ var monitor_2 = new sp_diagnostics_1._QosMonitor('TeamsAppsClient.RequestAppsPermissions');
199
+ requestPermissionsPromise = this._msGraphClient
200
+ .then(function (client) {
201
+ return client.api(_this._getCheckPermissionsUrl(uniqueAppIds)).version(MS_GRAPH_API_VERSION).get();
202
+ })
203
+ .then(function (response) {
204
+ if (response.error) {
205
+ monitor_2.writeUnexpectedFailure('RequestFailed', new Error(response.error.message));
206
+ return new Set();
207
+ }
208
+ var allowedApps = new Set();
209
+ response.value.map(function (item) {
210
+ allowedApps.add(item.id);
211
+ });
212
+ monitor_2.writeSuccess();
213
+ return allowedApps;
214
+ })
215
+ .catch(function (error) {
216
+ monitor_2.writeUnexpectedFailure(undefined, error);
217
+ return new Set();
218
+ });
219
+ }
220
+ // store the promise to avoid multiple requests to the API for the same teamsAppId
221
+ uniqueAppIds.forEach(function (teamsAppId) {
222
+ _this._appComponentsPermissionsPromises.set(teamsAppId, requestPermissionsPromise);
223
+ });
224
+ return requestPermissionsPromise;
225
+ };
226
+ TeamsAppsClient.prototype._requestAppsPermissionsBatched = function (appIds) {
227
+ var monitor = new sp_diagnostics_1._QosMonitor('TeamsAppsClient.RequestAppsPermissionsBatched');
228
+ var allowedApps = new Set();
229
+ //
230
+ // MS Graph batch body is like that:
231
+ // {
232
+ // "requests": [
233
+ // {
234
+ // "id": "1",
235
+ // "method": "GET",
236
+ // "url": "our-permissions-url"
237
+ // },
238
+ // {
239
+ // etc.
240
+ // }
241
+ // ]
242
+ // }
243
+ // We need to split the list of app ids to have no more than 10 requests per batch and no more than 30 ids per request
244
+ //
245
+ // we can have MAX_IDS_WITHOUT_BATCHING per one request in batch. And up to MAX_REQUESTS_PER_BATCH requests in batch.
246
+ var maxIdsPerBatch = MAX_IDS_WITHOUT_BATCHING * MAX_REQUESTS_PER_BATCH;
247
+ var batchesCount = Math.ceil(appIds.length / maxIdsPerBatch);
248
+ var batchIndex = 0;
249
+ var batchRequests = [];
250
+ try {
251
+ while (batchIndex < batchesCount) {
252
+ var batchBody = {
253
+ requests: []
254
+ };
255
+ var batchStartIndex = batchIndex * maxIdsPerBatch;
256
+ var batchEndIndex = Math.min(batchStartIndex + maxIdsPerBatch, appIds.length);
257
+ var batchIdStartIndex = batchStartIndex;
258
+ while (batchIdStartIndex < batchEndIndex) {
259
+ var batchIdEndIndex = batchIdStartIndex + MAX_IDS_WITHOUT_BATCHING;
260
+ var batchIds = appIds.slice(batchIdStartIndex, batchIdEndIndex);
261
+ batchBody.requests.push({
262
+ id: batchIdStartIndex.toString(),
263
+ method: 'GET',
264
+ url: this._getCheckPermissionsUrl(batchIds)
265
+ });
266
+ batchIdStartIndex = batchIdEndIndex;
267
+ }
268
+ batchRequests.push(batchBody);
269
+ batchIndex++;
270
+ }
271
+ }
272
+ catch (error) {
273
+ monitor.writeUnexpectedFailure('BatchSplitLogicError', error);
274
+ // Early return to avoid the request
275
+ return Promise.resolve(allowedApps);
276
+ }
277
+ var errors = [];
278
+ return this._msGraphClient
279
+ .then(function (client) {
280
+ var batchPromises = batchRequests.map(function (batchBody) {
281
+ return client
282
+ .api('$batch')
283
+ .version(MS_GRAPH_API_VERSION)
284
+ .post(batchBody)
285
+ .then(function (response) {
286
+ response.responses.forEach(function (responseItem) {
287
+ if (responseItem.status !== 200) {
288
+ errors.push(new Error(responseItem.body.error.message));
289
+ return;
290
+ }
291
+ responseItem.body.value.map(function (app) {
292
+ allowedApps.add(app.id);
293
+ });
294
+ });
295
+ })
296
+ .catch(function (error) {
297
+ errors.push(error);
298
+ });
299
+ });
300
+ return Promise.all(batchPromises);
301
+ })
302
+ .then(function () {
303
+ // some batches failed
304
+ if (errors.length) {
305
+ monitor.writeUnexpectedFailure('SomeBatchRequestsError', undefined, {
306
+ errors: errors
307
+ });
308
+ }
309
+ return allowedApps;
310
+ })
311
+ .catch(function (error) {
312
+ // all batches failed
313
+ monitor.writeUnexpectedFailure('BatchRequestError', error);
314
+ return new Set();
315
+ });
316
+ };
317
+ TeamsAppsClient.prototype._getCheckPermissionsUrl = function (appIds) {
318
+ return "".concat(MS_GRAPH_TEAMS_APPS_ENDPOINT, "?").concat(MS_GRAPH_CHECK_PERMISSIONS_QSP.replace('{appIds}', appIds.join("','")));
319
+ };
320
+ Object.defineProperty(TeamsAppsClient.prototype, "_msGraphClient", {
321
+ get: function () {
322
+ if (!this._msGraphClientFactory) {
323
+ this._msGraphClientFactory = this._serviceScope.consume(sp_http_1.MSGraphClientFactory.serviceKey);
324
+ }
325
+ if (!this._msGraphClientDeferred) {
326
+ this._msGraphClientDeferred = this._msGraphClientFactory.getClientInternal('3');
327
+ }
328
+ return this._msGraphClientDeferred;
329
+ },
330
+ enumerable: false,
331
+ configurable: true
332
+ });
333
+ TeamsAppsClient.prototype._teamsAppCatalogItemToAceManifests = function (item) {
334
+ var _this = this;
335
+ var _a;
336
+ //
337
+ // collect components that use Teams App icon instead of having its own
338
+ // if there are such components, we will need to fetch the app icon
339
+ //
340
+ var iconPromise;
341
+ var colorIconWebUrl = (_a = item.appDefinitions[0].colorIcon) === null || _a === void 0 ? void 0 : _a.webUrl;
342
+ var manifestsWithoutIcon = [];
343
+ var dashboardCards = item.appDefinitions[0].dashboardCards || [];
344
+ var manifests = [];
345
+ dashboardCards.forEach(function (dashboardCard) {
346
+ var _a, _b;
347
+ var component = {
348
+ appId: item.id,
349
+ externalAppId: item.externalId || undefined,
350
+ componentId: dashboardCard.id,
351
+ groupId: ADVANCED_TOOLBOX_GROUP_ID,
352
+ iconUrl: (_a = dashboardCard.icon) === null || _a === void 0 ? void 0 : _a.iconUrl,
353
+ officeUIFabricIconName: (_b = dashboardCard.icon) === null || _b === void 0 ? void 0 : _b.officeUIFabricIconName,
354
+ description: dashboardCard.description,
355
+ name: dashboardCard.displayName,
356
+ botId: dashboardCard.contentSource.botConfiguration.botId,
357
+ appName: item.displayName,
358
+ appDescription: item.appDefinitions[0].description,
359
+ version: item.appDefinitions[0].version,
360
+ // size is lower case in the manifest
361
+ defaultSize: "".concat(dashboardCard.defaultSize.charAt(0).toUpperCase()).concat(dashboardCard.defaultSize.slice(1))
362
+ };
363
+ var manifest = _this._teamsAppComponentToAceManifest(component);
364
+ manifests.push(manifest);
365
+ if (!component.iconUrl && !component.officeUIFabricIconName) {
366
+ manifestsWithoutIcon.push(manifest);
367
+ if (!iconPromise && colorIconWebUrl)
368
+ iconPromise = _this._msGraphClient.then(function (client) {
369
+ return client
370
+ .api(colorIconWebUrl)
371
+ .responseType('blob')
372
+ .get();
373
+ });
374
+ }
375
+ });
376
+ var resultPromise = Promise.resolve(manifests);
377
+ if (manifestsWithoutIcon.length && iconPromise) {
378
+ resultPromise = iconPromise
379
+ .then(function (response) {
380
+ return _this._convertBlobToBase64(response);
381
+ })
382
+ .then(function (iconUrl) {
383
+ manifestsWithoutIcon.forEach(function (manifest) {
384
+ manifest.preconfiguredEntries[0].iconImageUrl = iconUrl;
385
+ manifest.properties.teamsAppComponent.iconUrl = iconUrl;
386
+ });
387
+ return manifests;
388
+ });
389
+ }
390
+ return resultPromise;
391
+ };
392
+ TeamsAppsClient.prototype._convertBlobToBase64 = function (blob) {
393
+ return new Promise(function (resolve, reject) {
394
+ var reader = new FileReader();
395
+ reader.onerror = reject;
396
+ reader.onload = function () {
397
+ var base64String = reader.result;
398
+ if (!base64String) {
399
+ reject('');
400
+ }
401
+ resolve(base64String.substr(base64String.indexOf(', ') + 1));
402
+ };
403
+ reader.readAsDataURL(blob);
404
+ });
405
+ };
406
+ TeamsAppsClient.prototype._teamsAppComponentToAceManifest = function (component) {
407
+ return {
408
+ id: component.componentId,
409
+ manifestVersion: MANIFEST_VERSION,
410
+ version: component.version,
411
+ componentType: 'AdaptiveCardExtension',
412
+ alias: component.componentId,
413
+ properties: {
414
+ teamsAppComponent: component
415
+ },
416
+ loaderConfig: {
417
+ entryModuleId: component.componentId,
418
+ internalModuleBaseUrls: ['HTTPS://CLIENTSIDEASSETSLIBRARY/'],
419
+ scriptResources: {}
420
+ },
421
+ preconfiguredEntries: [
422
+ {
423
+ cardSize: component.defaultSize,
424
+ title: {
425
+ default: component.name
426
+ },
427
+ description: {
428
+ default: component.description
429
+ },
430
+ iconImageUrl: component.iconUrl,
431
+ officeFabricIconFontName: component.officeUIFabricIconName,
432
+ groupId: component.groupId,
433
+ properties: {}
434
+ }
435
+ ],
436
+ connectedTeamsAppId: component.appId,
437
+ isPendingTeamsAppSync: true
438
+ };
439
+ };
440
+ return TeamsAppsClient;
441
+ }());
442
+ exports.TeamsAppsClient = TeamsAppsClient;
443
+ //# sourceMappingURL=TeamsAppsClient.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/sp-component-base",
3
- "version": "1.18.2",
3
+ "version": "1.19.0-rc.0",
4
4
  "description": "SharePoint Framework support for building client-side components",
5
5
  "license": "https://aka.ms/spfx/license",
6
6
  "homepage": "http://aka.ms/spfx",
@@ -11,29 +11,30 @@
11
11
  "tsdocFlavor": "AEDoc"
12
12
  },
13
13
  "devDependencies": {
14
- "@rushstack/heft": "0.62.1",
14
+ "@rushstack/heft": "0.66.0",
15
15
  "@types/react": "17.0.45",
16
16
  "@types/react-dom": "17.0.17",
17
17
  "eslint": "8.7.0",
18
18
  "react": "17.0.1",
19
19
  "react-dom": "17.0.1",
20
- "@ms/office-ui-fabric-react-bundle": "1.18.6",
21
- "@ms/react-17-bundle": "17.0.1",
20
+ "@ms/office-ui-fabric-react-bundle": "1.19.0",
21
+ "@ms/ms-graph-v3-bundle": "3.0.2",
22
22
  "@ms/react-dom-17-bundle": "17.0.1",
23
+ "@ms/react-17-bundle": "17.0.1",
23
24
  "@ms/react-dom-17-profiling-bundle": "17.0.1",
24
- "@ms/sp-telemetry": "0.31.35",
25
+ "@ms/sp-telemetry": "0.32.6",
25
26
  "@ms/spfx-internal-web-build-rig": "0.1.0"
26
27
  },
27
28
  "dependencies": {
28
29
  "@fluentui/react": "^8.110.12",
29
30
  "tslib": "2.3.1",
30
- "@microsoft/sp-core-library": "1.18.2",
31
- "@microsoft/sp-diagnostics": "1.18.2",
32
- "@microsoft/sp-dynamic-data": "1.18.2",
33
- "@microsoft/sp-http": "1.18.2",
34
- "@microsoft/sp-lodash-subset": "1.18.2",
35
- "@microsoft/sp-module-interfaces": "1.18.2",
36
- "@microsoft/sp-page-context": "1.18.2"
31
+ "@microsoft/sp-core-library": "1.19.0-rc.0",
32
+ "@microsoft/sp-diagnostics": "1.19.0-rc.0",
33
+ "@microsoft/sp-dynamic-data": "1.19.0-rc.0",
34
+ "@microsoft/sp-http": "1.19.0-rc.0",
35
+ "@microsoft/sp-page-context": "1.19.0-rc.0",
36
+ "@microsoft/sp-module-interfaces": "1.20.1",
37
+ "@microsoft/sp-lodash-subset": "1.19.0-rc.0"
37
38
  },
38
39
  "engines": {
39
40
  "node": ">=18.17.1 <19.0.0"