// packages/abstract-apis/src/functions/share_utils.ts import { getEndpoint } from './endpoint_utils'; import {getAuthorizationHeader,fetchIt} from "@putkoff/abstract-utilities"; export async function fetchSharePatch( opts: any ): Promise { const url = `https://api.abstractendeavors.com/secure-files/files/share`; const res = await fetch(url, { method: 'POST', headers: getAuthorizationHeader({ 'Content-Type': 'application/json' }), credentials: 'include', body: JSON.stringify(opts), }); if (!res.ok) { throw new Error(`Patch failed: ${res.status} ${res.statusText}`); } return res.json(); } /** * Makes a secure fetch through your API gateway. */ export async function secureFetchIt( endpoint: any, body: any = null, method: any = null, headers: Record | null = null, blob: boolean = false, noApi: boolean = true, withCredentials: boolean = true, returnJson: boolean = true, returnResult: boolean = true ): Promise { const url = await getEndpoint(endpoint); // fetchIt returns either JSON or Blob based on args, // but we unify to T here. const result = await fetchIt( url, body, method, headers, blob, noApi, withCredentials, returnJson, returnResult ); return result as T; }