@mikezimm/fps-core-v7
Version:
Library of reusable core interfaces, types and constants migrated from fps-library-v2
51 lines • 2.93 kB
JavaScript
import { doSpHttpFetchOrPostAndCheck } from '../../../components/molecules/SpHttp/Sp/doSpHttpFetch';
import { check4This, Check4 } from '../../../logic/Links/CheckSearch';
import { createErrorFpsListReturn } from '../../../components/molecules/process-results/createErrorFpsListItemsReturn';
import { SourcePropsNoWebUrl } from '../../../components/molecules/source-props/ISourceProps';
import { getAbsoluteWebUrlFromSourceProps, } from '../../../logic/Strings/getAbssoluteWebUrlFromSourceProps';
import { getExpandColumns } from '../../../components/molecules/source-props/Lists/getVX/getExpandV2';
import { GroupSelectsWithOwner } from './GroupSelects';
import { getCollectionUrl } from '../../../logic/Links/getSPOUrl';
export async function getWebGroupInfoAPI(sourceProps, alertMe, consoleLog) {
const { restFilter, selectThese = GroupSelectsWithOwner, } = sourceProps;
// const performanceSettings: IPerformanceSettings = { label: `SiteGroups`, includeMsStr: true, updateMiliseconds: true, op: 'fetch' };
// const fetchOp: IPerformanceOp = startPerformOpV2( performanceSettings ) as IPerformanceOp; // 2024-09-29: set null as any to pass build error.
const useUrl = getAbsoluteWebUrlFromSourceProps(sourceProps);
if (!useUrl) {
// NO WebURL... Throw Alert
if (alertMe === true)
alert(`getGroupInfoAPI: ${SourcePropsNoWebUrl}`);
const results = createErrorFpsListReturn(useUrl, '');
return results;
}
/**
SAMPLE Full SharePoint Items Rest call:
``${this.props.SettingsSource.useUrl}/
_api/web/sitegroups?
$filter=startswith(Title,'EULA')&
$select=Title,Id`;
*/
let fetchAPI = `${useUrl}/_api/web/sitegroups?`;
fetchAPI += `&$orderby=Title asc`;
fetchAPI += `&$select=${selectThese.length > 0 ? selectThese.join(',') : 'Title,Id,PrincipalType,'}`;
const expandThese = getExpandColumns(selectThese);
if (expandThese.length > 0)
fetchAPI += `&$expand=${expandThese.join(',')}`;
if (restFilter)
fetchAPI += `&$filter=${restFilter}`;
const result = await doSpHttpFetchOrPostAndCheck(fetchAPI, 'GET', sourceProps.fpsSpService, '', alertMe, consoleLog, 'groups', false, null);
// result.groups = result.items ? result.items : [];
// result.fpsContentType = [ 'group' ];
result.unifiedPerformanceOps.fetch.label = `${getCollectionUrl(useUrl)} Groups`;
// result.unifiedPerformanceOps.fetch.c = result.groups.length;
// Add any required custom logic here
// if ( resultHubSites.ok ) {
// resultHubSites.items = cleanSearchedWebs( resultHubSites.items );
// }
if (check4This(Check4.fpsShowFetchResults_Eq_true) === true) {
console.log(`fps-core-v7 COMPLETE: getWebGroupInfoAPI ~ 61`, result);
}
;
return result;
}
//# sourceMappingURL=getWebGroupInfoAPI.js.map