@@ -27,15 +27,22 @@ import ArrowUpFromLineIcon from '@gravity-ui/icons/svgs/arrow-up-from-line.svg';
2727
2828import './JsonViewer.scss' ;
2929
30- interface JsonViewerProps {
31- value : UnipikaValue ;
30+ interface JsonViewerCommonProps {
3231 unipikaSettings ?: UnipikaSettings ;
3332 extraTools ?: React . ReactNode ;
3433 tableSettings ?: DT100 . Settings ;
3534 search ?: boolean ;
3635 collapsedInitially ?: boolean ;
3736}
3837
38+ interface JsonViewerProps extends JsonViewerCommonProps {
39+ value : UnipikaValue | { _error : string } ;
40+ }
41+
42+ interface JsonViewerComponentProps extends JsonViewerCommonProps {
43+ value : UnipikaValue ;
44+ }
45+
3946interface State {
4047 flattenResult : FlattenUnipikaResult ;
4148 value : JsonViewerProps [ 'value' ] ;
@@ -88,14 +95,26 @@ function calculateState(
8895 ) ;
8996}
9097
91- export function JsonViewer ( {
98+ function isUnipikaValue ( value : UnipikaValue | { _error : string } ) : value is UnipikaValue {
99+ return ! ( '_error' in value ) ;
100+ }
101+
102+ export function JsonViewer ( props : JsonViewerProps ) {
103+ const { value} = props ;
104+ if ( ! isUnipikaValue ( value ) ) {
105+ return value . _error ;
106+ }
107+ return < JsonViewerComponent { ...props } value = { value } /> ;
108+ }
109+
110+ function JsonViewerComponent ( {
92111 tableSettings,
93112 value,
94113 unipikaSettings,
95114 search = true ,
96115 extraTools,
97116 collapsedInitially,
98- } : JsonViewerProps ) {
117+ } : JsonViewerComponentProps ) {
99118 const [ caseSensitiveSearch , setCaseSensitiveSearch ] = useSetting (
100119 CASE_SENSITIVE_JSON_SEARCH ,
101120 false ,
0 commit comments