UNPKG

@pnp/spfx-property-controls

Version:

Reusable property pane controls for SharePoint Framework solutions

41 lines 1.79 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const GraphHelper_1 = require("../helpers/GraphHelper"); /** * Service implementation to search sites in SharePoint */ class TeamsSearchService { /** * Search sites from the SharePoint */ searchTeams(ctx, query) { return tslib_1.__awaiter(this, void 0, void 0, function* () { const msGraphClient = yield ctx.msGraphClientFactory.getClient('3'); const listOfTeamsResults = yield msGraphClient // eslint-disable-line @typescript-eslint/no-explicit-any .api(`/me/joinedTeams?$filter=startswith(displayName,'${query}')&$select=id,displayName`) .version("v1.0") .get(); const listOfTeams = listOfTeamsResults.value; // eslint-disable-line @typescript-eslint/no-explicit-any const res = []; if (listOfTeams && listOfTeams.length > 0) { const batchRequests = []; listOfTeams.forEach((t) => { batchRequests.push({ id: t.id, method: 'GET', url: `/groups/${t.id}/drive/root?$select=webUrl` }); }); const batchResponses = yield (0, GraphHelper_1.batch)(batchRequests, 'v1.0', ctx); for (const team of listOfTeams) { const webUrl = batchResponses.filter(br => br.id === team.id)[0].body.webUrl; res.push({ id: team.id, title: team.displayName, url: webUrl }); } } return res; }); } } exports.default = TeamsSearchService; //# sourceMappingURL=TeamsSearchService.js.map