Adding new API CRUD v3 functionality.
This commit is contained in:
50
src/lib/ae_api/api_post__crud_search_v3.ts
Normal file
50
src/lib/ae_api/api_post__crud_search_v3.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import type { key_val } from '$lib/stores/ae_stores';
|
||||
import { post_object } from './api_post_object';
|
||||
|
||||
interface SearchAeObjV3Params {
|
||||
api_cfg: any;
|
||||
obj_type: string;
|
||||
search_query: any; // Complex SearchQuery object
|
||||
order_by_li?: Record<string, 'ASC' | 'DESC'> | null;
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
delay_ms?: number;
|
||||
log_lvl?: number;
|
||||
}
|
||||
|
||||
export async function search_ae_obj_v3({
|
||||
api_cfg,
|
||||
obj_type,
|
||||
search_query,
|
||||
order_by_li = null,
|
||||
limit = 100,
|
||||
offset = 0,
|
||||
delay_ms = 0,
|
||||
log_lvl = 0
|
||||
}: SearchAeObjV3Params) {
|
||||
const endpoint = `/v3/crud/${obj_type}/search`;
|
||||
|
||||
const params: key_val = {
|
||||
limit,
|
||||
offset
|
||||
};
|
||||
|
||||
if (order_by_li) params['order_by_li'] = JSON.stringify(order_by_li);
|
||||
if (delay_ms > 0) params['delay_ms'] = delay_ms;
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('*** search_ae_obj_v3 ***');
|
||||
console.log('Endpoint:', endpoint);
|
||||
console.log('Params:', params);
|
||||
console.log('Search Query:', search_query);
|
||||
}
|
||||
|
||||
// Note: search_query is sent in the BODY via POST
|
||||
return await post_object({
|
||||
api_cfg,
|
||||
endpoint,
|
||||
params,
|
||||
data: search_query,
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user