fix(core): clarify account fallback source and pretty-print _json payloads
This commit is contained in:
@@ -29,6 +29,22 @@ import {
|
||||
|
||||
import { get_data_store } from '$lib/ae_api/api_get__data_store';
|
||||
|
||||
const JSON_PRETTY_SPACES = 2;
|
||||
|
||||
function serialize_json_field_pretty(value: any) {
|
||||
if (value === null || value === undefined) return value;
|
||||
|
||||
if (typeof value === 'string') {
|
||||
try {
|
||||
return JSON.stringify(JSON.parse(value), null, JSON_PRETTY_SPACES);
|
||||
} catch {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
return JSON.stringify(value, null, JSON_PRETTY_SPACES);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of lookup objects (V3)
|
||||
* Standardized lookup data like countries, timezones, and subdivisions.
|
||||
@@ -165,7 +181,7 @@ export const create_ae_obj_crud = async function create_ae_obj_crud({
|
||||
if (log_lvl) {
|
||||
console.log(`${key}: ${value}`);
|
||||
}
|
||||
data['data_list'][key] = JSON.stringify(value);
|
||||
data['data_list'][key] = serialize_json_field_pretty(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -276,7 +292,7 @@ export const update_ae_obj_id_crud = async function update_ae_obj_id_crud({
|
||||
if (log_lvl) {
|
||||
console.log(`${key}: ${value}`);
|
||||
}
|
||||
data['data_list'][key] = JSON.stringify(value);
|
||||
data['data_list'][key] = serialize_json_field_pretty(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user