Skip to content
This repository was archived by the owner on May 13, 2025. It is now read-only.

Commit 377690e

Browse files
authored
fix: Detect schema JSON type fix (#436)
1 parent dfc2ff1 commit 377690e

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

src/hooks/useLogStream.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
import { useMutation, useQuery } from 'react-query';
1+
import { AxiosError, isAxiosError } from 'axios';
2+
import { appStoreReducers, useAppStore } from '@/layouts/MainLayout/providers/AppProvider';
23
import {
4+
createLogStream,
35
deleteLogStream,
6+
detectLogStreamSchema,
47
getLogStreamList,
5-
createLogStream,
68
updateLogStream,
7-
detectLogStreamSchema,
89
} from '@/api/logStream';
9-
import { AxiosError, isAxiosError } from 'axios';
1010
import { notifyError, notifySuccess } from '@/utils/notification';
11+
import { useMutation, useQuery } from 'react-query';
12+
1113
import { LogStreamSchemaData } from '@/@types/parseable/api/stream';
12-
import { appStoreReducers, useAppStore } from '@/layouts/MainLayout/providers/AppProvider';
1314

1415
type CreateStreamOpts = {
1516
streamName: string;
@@ -40,7 +41,7 @@ export const useLogStream = () => {
4041
isError: detectLogStreamSchemaIsError,
4142
isLoading: detectLogStreamSchemaIsLoading,
4243
} = useMutation(
43-
(data: { sampleLogs: any[]; onSuccess: (data: LogStreamSchemaData) => void }) =>
44+
(data: { sampleLogs: Record<string, any>; onSuccess: (data: LogStreamSchemaData) => void }) =>
4445
detectLogStreamSchema(data.sampleLogs),
4546
{
4647
onSuccess: (data, variables) => {

src/pages/Home/CreateStreamModal.tsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,17 @@ import {
1919
Tooltip,
2020
} from '@mantine/core';
2121
import { FC, useCallback, useEffect, useState } from 'react';
22-
import styles from './styles/CreateStreamModal.module.css';
23-
import { useLogStream } from '@/hooks/useLogStream';
24-
import { useForm } from '@mantine/form';
22+
import { GetInputPropsReturnType, UseFormReturnType } from 'node_modules/@mantine/form/lib/types';
2523
import { IconInfoCircleFilled, IconPlus } from '@tabler/icons-react';
26-
import _ from 'lodash';
24+
import { appStoreReducers, useAppStore } from '@/layouts/MainLayout/providers/AppProvider';
25+
2726
import { CreatableSelect } from '@/components/Misc/CreatableSelect';
28-
import { useAppStore, appStoreReducers } from '@/layouts/MainLayout/providers/AppProvider';
29-
import { GetInputPropsReturnType, UseFormReturnType } from 'node_modules/@mantine/form/lib/types';
30-
import { notifyError } from '@/utils/notification';
3127
import { LogStreamSchemaData } from '@/@types/parseable/api/stream';
28+
import _ from 'lodash';
29+
import { notifyError } from '@/utils/notification';
30+
import styles from './styles/CreateStreamModal.module.css';
31+
import { useForm } from '@mantine/form';
32+
import { useLogStream } from '@/hooks/useLogStream';
3233

3334
const { toggleCreateStreamModal } = appStoreReducers;
3435

@@ -461,9 +462,7 @@ const DetectSchemaSection = (props: { form: StreamFormType }) => {
461462
} catch (e) {
462463
console.error('Error parsing json', e);
463464
}
464-
if (!_.isArray(logRecords)) {
465-
return notifyError({ message: 'Invalid JSON' });
466-
} else if (_.isEmpty(logRecords)) {
465+
if (_.isEmpty(logRecords)) {
467466
return notifyError({ message: 'No records found' });
468467
} else if (_.size(logRecords) > 10) {
469468
return notifyError({ message: 'More than 10 records found' });

0 commit comments

Comments
 (0)