Various SDK improvements (#18115)
## Summary - **Refactor frontend metadata loading architecture**: Split the monolithic `EagerMetadataLoadEffect` into focused provider effects (`UserMetadataProviderEffect`, `ObjectMetadataProviderEffect`, `ViewMetadataProviderEffect`) orchestrated by `MetadataProviderEffects`. Replaced `UserProvider` + `ObjectMetadataItemsProvider` with a single `MetadataGater` that gates rendering on `isAppMetadataReadyState`. The metadata store now validates view-object consistency before promoting views, and `updateDraft` skips no-op updates via deep equality checks. - **SDK CLI improvements**: Added `app:typecheck` command, improved error handling in API sync (extracts GraphQL error messages), added `serializeError` utility for human-readable error output, added `error` file status to dev mode orchestrator with UI support, and fixed ClickHouse migration/seed commands to use `transpile-only`.
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
import axios from 'axios';
|
||||
|
||||
export const serializeError = (error: unknown): string => {
|
||||
if (typeof error === 'string') {
|
||||
return error;
|
||||
}
|
||||
|
||||
if (axios.isAxiosError(error)) {
|
||||
const parts: string[] = [];
|
||||
const status = error.response?.status;
|
||||
const statusText = error.response?.statusText;
|
||||
|
||||
if (status) {
|
||||
parts.push(`HTTP ${status}${statusText ? ` ${statusText}` : ''}`);
|
||||
}
|
||||
|
||||
const graphqlErrors = error.response?.data?.errors;
|
||||
|
||||
if (Array.isArray(graphqlErrors) && graphqlErrors.length > 0) {
|
||||
const messages = graphqlErrors
|
||||
.map(
|
||||
(graphqlError: { message?: string }) =>
|
||||
graphqlError.message ?? 'Unknown GraphQL error',
|
||||
)
|
||||
.join('; ');
|
||||
|
||||
parts.push(messages);
|
||||
} else if (error.response?.data?.message) {
|
||||
parts.push(error.response.data.message);
|
||||
} else if (error.message) {
|
||||
parts.push(error.message);
|
||||
}
|
||||
|
||||
if (error.code) {
|
||||
parts.push(`(${error.code})`);
|
||||
}
|
||||
|
||||
return parts.join(' - ') || 'Unknown Axios error';
|
||||
}
|
||||
|
||||
if (error instanceof Error) {
|
||||
return error.message || error.toString();
|
||||
}
|
||||
|
||||
const stringified = JSON.stringify(error, null, 2);
|
||||
|
||||
if (stringified === '{}' || stringified === undefined) {
|
||||
return String(error);
|
||||
}
|
||||
|
||||
return stringified;
|
||||
};
|
||||
Reference in New Issue
Block a user