@mikezimm/fps-core-v7
Version:
Library of reusable core interfaces, types and constants migrated from fps-library-v2
72 lines (68 loc) • 3.48 kB
TypeScript
/**
* 2024-09-15: Migrated to SAME FOLDER in fps-library-v2\src\components\molecules\SpHttp...
* export { IJSFetchReturn, createEmptyFetchReturn, doSpJsFetch }
*/
import { IFPSBaseContentTypesAll } from '../../../../types/fps-returns/common/IFPSBaseContentType';
import { IFpsItemsReturn } from '../../process-results/IFpsItemsReturn';
import { IJSFetchMethodNoPUT, IJSFetchReturn } from '../interfaces/IJSFetchReturn';
export declare function doSpJsFetch(fetchAPI: string, digestValue: string, headerContentType: string): Promise<IJSFetchReturn>;
/**
*
* Pass in any SharePoint rest api url and it should return a result or a standard error return object
* 2024-12-09: changed from accepting headerContentType to headers.
* old default was: 'Content-Type': headerContentType ? headerContentType : 'application/json;odata=verbose',
* ALSO, NEED TO add requestDigest into customHeaders like this:
* headers[ 'X-RequestDigest' ] = digestValue
*
* for Updates:
* Use 'MERGE' for updating items
*
* customHeaders: HeadersInit update
*
*
* TOP THINGS TO Look for debugging
* 1. __metadata: for ALL SAVE ITEMS
* 2. null for body if there is no body
*
*
* @param fetchAPI
* @returns
*/
export declare function doSpJsFetchOrPost(fetchAPI: string, method: IJSFetchMethodNoPUT, customHeaders: HeadersInit, body: any, forcedHeaders?: HeadersInit, retryCount?: number, delayTime?: number): Promise<IJSFetchReturn>;
/**
* doSpJsFetchOrPostAndCheck does: the fetch, checkItemsResults, adds fpsContentTypes and performance
*
* Use 'MERGE' for updating items
*
* Steps to use this vs the No Check:
* 1. Update call
const result: IFpsUsersReturn = await doSpJsFetchOrPostAndCheck( fetchAPI, 'GET', digestValue, '', false, true, null ) as unknown as IFpsUsersReturn;
*
* 4. re-assign performance object, update label
result.unifiedPerformanceOps.fetch.label = 'GroupName';
initialResult.fetchOp = initialResult.unifiedPerformanceOps.fetch;
*
* Things to remove from the older version calls
* const performanceSettings: IPerformanceSettings = { label: 'FetchCheck', includeMsStr: true, updateMiliseconds: true, op: 'fetch' };
* const fetchOp = performanceSettings ? startPerformOpV2( performanceSettings ) : null;
* DONE HERE based on 'type' property: move results to the object you want
result.users = result.items ? result.items : [];
DONE HERE based on 'type' property: update fpsContentType
result.fpsContentType = [ 'user' ];
* initialResult.unifiedPerformanceOps.fetch = performanceSettings ?
updatePerformanceEndV2( { op: fetchOp as IPerformanceOp, updateMiliseconds: performanceSettings.updateMiliseconds, count: initialResult.items ? initialResult.items.length : 0 })
: null as any; // 2024-09-29: set null as any to pass build error
*
*
* @param fetchAPI
* @param method
* @param digestValue
* @param headerContentType
* @param type
* @param alertMe
* @param consoleLog
* @param body
* @returns
*/
export declare function doSpJsFetchOrPostAndCheck(fetchAPI: string, method: IJSFetchMethodNoPUT, digestValue: string, headerContentType: string, alertMe: boolean | undefined, consoleLog: boolean | undefined, type: IFPSBaseContentTypesAll, body: any, forcedHeaders?: HeadersInit): Promise<IFpsItemsReturn>;
//# sourceMappingURL=doSpJsFetch.d.ts.map