690530:0906 ADR-030-230 context aware #12
CI / CD Pipeline / build (push) Successful in 4m54s
CI / CD Pipeline / deploy (push) Successful in 7m49s

This commit is contained in:
2026-05-30 09:06:23 +07:00
parent 63ded10341
commit 1ba563aa70
3 changed files with 460 additions and 14 deletions
+6 -6
View File
@@ -7,10 +7,13 @@ import api from '../api/client';
import { AiPrompt } from '../../types/ai-prompts';
const extractData = <T>(value: unknown): T => {
if (value && typeof value === 'object' && 'data' in value) {
return (value as { data: T }).data;
let current: unknown = value;
let depth = 0;
while (current && typeof current === 'object' && 'data' in current && depth < 5) {
current = (current as { data: unknown }).data;
depth += 1;
}
return value as T;
return current as T;
};
/**
@@ -18,9 +21,6 @@ const extractData = <T>(value: unknown): T => {
*/
const unwrapResponse = <T>(value: unknown): T => {
const extracted = extractData<T>(value);
if (extracted && typeof extracted === 'object' && 'data' in extracted) {
return (extracted as { data: T }).data;
}
return extracted;
};