UNPKG

@mikezimm/fps-core-v7

Version:

Library of reusable core interfaces, types and constants migrated from fps-library-v2

74 lines (73 loc) 4.28 kB
/** * CodeAnalizerComment: Updated 10 imports on 2024-09-21 23:07:24 * Update:: import { IJSFetchReturn } to '@mikezimm/fps-core-v7/lib/components/molecules/SpHttp/doSpHttpFetchOrPostAndCheck;' * Update:: import { createEmptyFetchReturn } to '@mikezimm/fps-core-v7/lib/components/molecules/SpHttp/doSpJsFetch;' * Update:: import { doSpJsFetch } to '@mikezimm/fps-core-v7/lib/components/molecules/SpHttp/doSpJsFetch;' * Update:: import { IPerformanceSettings } to '@mikezimm/fps-core-v7/lib/components/molecules/Performance/IPerformanceSettings;' * Update:: import { startPerformOpV2 } to '@mikezimm/fps-core-v7/lib/components/molecules/Performance/functions;' * Update:: import { unifiedPerformanceEnd } to '@mikezimm/fps-core-v7/lib/components/molecules/Performance/functions;' * Update:: import { IFpsErrorObject } to '@mikezimm/fps-core-v7/lib/types/fps-returns/common/IFpsErrorObject;' * Update:: import { IFpsItemsReturn } to '@mikezimm/fps-core-v7/lib/components/molecules/process-results/CheckItemsResults;' * Update:: import { checkItemsResults } to '@mikezimm/fps-core-v7/lib/components/molecules/process-results/CheckItemsResults;' * Update:: import { WebPartContextCopy_15_2 } to '@mikezimm/fps-core-v7/lib/types/@msft/1.15.2/WebPartContext;' */ import { doSpHttpFetchOrPostAndCheck } from '../../../../components/molecules/SpHttp/Sp/doSpHttpFetch'; import { createEmptyFetchReturn } from "../../../../components/molecules/SpHttp/interfaces/IJSFetchReturn"; // import { WebPartContextCopy_15_2 } from '../../../../types/@msft/1.15.2/WebPartContext'; //./../../../common/interfaces/indexes/WebPartContext@152'; import { CurrentOrigin } from '../../../../components/molecules/source-props/WindowLocationConstants'; // THIS SHOULD COME FROM doSpHttpFetchOrPostAndCheck file // export function createEmptyFetchReturn( fetchAPI: string ): IJSFetchReturn { // const emptyObject: IJSFetchReturn = { // items: [], // ok: null, // e: null, // status: 'Unknown', // fetchAPI: fetchAPI, // } // return emptyObject; // } /** * * @param context * @param filesLocation * @param postFilters : would be string array of valid extensions to return * @returns */ export async function fetchListList(fpsSpService, web, filter) { let websLocation = web; if (web && web.indexOf('/sites/') === 0) { websLocation = CurrentOrigin + websLocation; } if (websLocation.slice(-1) !== '/') { websLocation += '/'; } // const performanceSettings: IPerformanceSettings = { label: 'myHubs', updateMiliseconds: true, includeMsStr: true, op: 'fetch' }; // const fetchOp = performanceSettings ? startPerformOpV2( performanceSettings ) : null; // 2025-01-21: Expanding the Root Folder here based upon testing for PivotTiles const apiFetchLibsQuery = `${websLocation}_api/Web/Lists?$filter=${filter}&select=Title,EntityTypeName,BaseType,ParentWebUrl,RootFolder/ServerRelativeUrl&expand=RootFolder`; if (!web) return createEmptyFetchReturn(apiFetchLibsQuery, 'GET'); const result = await doSpHttpFetchOrPostAndCheck(apiFetchLibsQuery, 'GET', fpsSpService, '', false, true, 'list', false, null); if (result.ok) result.items = cleanWebLists(result.items); // let result : IJSFetchReturn = unifiedPerformanceEnd( resultFileList as IFpsErrorObject, performanceSettings, fetchOp as IPerformanceOp, 'fetch', 'items' ); // result.fpsContentType = [ 'list' ]; // result = checkItemsResults( result as IFpsItemsReturn, `fps-core-v7: fetchFileList ~ 69`, false, true ); return result; } export function cleanWebLists(ListPickerInfo) { // Do postFilters here //Issue #6 & #7 ListPickerInfo.map(list => { const listRelativeURL = list.RootFolder ? list.RootFolder.ServerRelativeUrl : list.BaseType === 1 ? `${list.ParentWebUrl}/${list.EntityTypeName}` : `${list.ParentWebUrl}/lists/${list.EntityTypeName}`; list.siteRelativeURL = `${list.ParentWebUrl}`; list.text = list.Title; list.list = list.EntityTypeName; list.key = listRelativeURL; }); return ListPickerInfo; } //# sourceMappingURL=fetchListList.js.map