Last round of prettier: npx prettier --write src/

This commit is contained in:
Scott Idem
2026-03-24 13:27:40 -04:00
parent 23d25bf65a
commit a8f3c29b9f
146 changed files with 13201 additions and 9277 deletions

View File

@@ -43,7 +43,9 @@ export const delete_object = async function delete_object({
// Construct the URL with query parameters
const url = new URL(endpoint, api_cfg['base_url']);
if (params) {
Object.keys(params).forEach((key) => url.searchParams.append(key, params[key]));
Object.keys(params).forEach((key) =>
url.searchParams.append(key, params[key])
);
}
// Clean and merge headers without mutating the original api_cfg
@@ -70,8 +72,13 @@ export const delete_object = async function delete_object({
}
// Auto-inject Authorization header if JWT is present but header is missing
const jwt = headers_cleaned['jwt'] || headers_cleaned['JWT'] || api_cfg['jwt'];
if (jwt && !headers_cleaned['Authorization'] && !headers_cleaned['authorization']) {
const jwt =
headers_cleaned['jwt'] || headers_cleaned['JWT'] || api_cfg['jwt'];
if (
jwt &&
!headers_cleaned['Authorization'] &&
!headers_cleaned['authorization']
) {
headers_cleaned['Authorization'] = `Bearer ${jwt}`;
}
@@ -93,20 +100,26 @@ export const delete_object = async function delete_object({
try {
const controller = new AbortController();
const timeoutId = setTimeout(() => {
console.error(`API DELETE request timed out after ${timeout}ms.`);
console.error(
`API DELETE request timed out after ${timeout}ms.`
);
controller.abort();
}, timeout);
const fetchOptions: RequestInit = {
method: 'DELETE',
headers: headers_cleaned,
body: Object.keys(data).length > 0 ? JSON.stringify(data) : undefined,
body:
Object.keys(data).length > 0
? JSON.stringify(data)
: undefined,
signal: controller.signal
};
const response = await fetch_method(url.toString(), fetchOptions).catch(function (
error: any
) {
const response = await fetch_method(
url.toString(),
fetchOptions
).catch(function (error: any) {
console.log(
'API DELETE Object *fetch* request was aborted or failed in an unexpected way.',
error
@@ -121,7 +134,9 @@ export const delete_object = async function delete_object({
}
if (log_lvl) {
console.log(`Response: status=${response.status} attempt=${attempt}`);
console.log(
`Response: status=${response.status} attempt=${attempt}`
);
}
if (!response.ok) {
@@ -129,15 +144,20 @@ export const delete_object = async function delete_object({
console.warn('404 Not Found. Returning null.');
return null;
}
const errorBody = await response.text();
console.error(`HTTP error! status: ${response.status}`, errorBody);
console.error(
`HTTP error! status: ${response.status}`,
errorBody
);
if (response.status >= 400 && response.status < 404) {
return false;
}
throw new Error(`HTTP error! status: ${response.status} - ${errorBody}`);
throw new Error(
`HTTP error! status: ${response.status} - ${errorBody}`
);
}
const json = await response.json();
@@ -148,7 +168,11 @@ export const delete_object = async function delete_object({
// Return the response data or metadata
// Robustly handle V3 response envelopes
return return_meta ? json : (json.data !== undefined ? json.data : json);
return return_meta
? json
: json.data !== undefined
? json.data
: json;
} catch (error) {
console.error(`API DELETE error on attempt ${attempt}:`, error);