Skip to content

Commit

Permalink
fix: Detect schema JSON type fix
Browse files Browse the repository at this point in the history
  • Loading branch information
praveen5959 committed Jan 24, 2025
1 parent 16e3a8a commit f9f0337
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 21 deletions.
15 changes: 8 additions & 7 deletions src/hooks/useLogStream.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { appStoreReducers, useAppStore } from '@/layouts/MainLayout/providers/AppProvider';
import { AxiosError, isAxiosError } from 'axios';
import { LogStreamSchemaData } from '@/@types/parseable/api/stream';
import { notifyError, notifySuccess } from '@/utils/notification';
import { useMutation, useQuery } from 'react-query';
import {
createLogStream,
deleteLogStream,
detectLogStreamSchema,
getLogStreamList,
createLogStream,
updateLogStream,
detectLogStreamSchema,
} from '@/api/logStream';
import { AxiosError, isAxiosError } from 'axios';
import { notifyError, notifySuccess } from '@/utils/notification';
import { LogStreamSchemaData } from '@/@types/parseable/api/stream';
import { appStoreReducers, useAppStore } from '@/layouts/MainLayout/providers/AppProvider';


Check failure on line 14 in src/hooks/useLogStream.tsx

View workflow job for this annotation

GitHub Actions / prettier

Delete `⏎`
type CreateStreamOpts = {
streamName: string;
Expand Down Expand Up @@ -40,7 +41,7 @@ export const useLogStream = () => {
isError: detectLogStreamSchemaIsError,
isLoading: detectLogStreamSchemaIsLoading,
} = useMutation(
(data: { sampleLogs: any[]; onSuccess: (data: LogStreamSchemaData) => void }) =>
(data: { sampleLogs: Record<string, any>; onSuccess: (data: LogStreamSchemaData) => void }) =>
detectLogStreamSchema(data.sampleLogs),
{
onSuccess: (data, variables) => {
Expand Down
32 changes: 18 additions & 14 deletions src/pages/Home/CreateStreamModal.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
import _ from 'lodash';
import styles from './styles/CreateStreamModal.module.css';
import { appStoreReducers, useAppStore } from '@/layouts/MainLayout/providers/AppProvider';
import { CreatableSelect } from '@/components/Misc/CreatableSelect';
import {

Check failure on line 5 in src/pages/Home/CreateStreamModal.tsx

View workflow job for this annotation

GitHub Actions / prettier

Replace `⏎↹FC,⏎↹useCallback,⏎↹useEffect,⏎↹useState⏎↹` with `·FC,·useCallback,·useEffect,·useState·`
FC,
useCallback,
useEffect,
useState
} from 'react';
import { GetInputPropsReturnType, UseFormReturnType } from 'node_modules/@mantine/form/lib/types';
import { IconInfoCircleFilled, IconPlus } from '@tabler/icons-react';
import { LogStreamSchemaData } from '@/@types/parseable/api/stream';
import { notifyError } from '@/utils/notification';
import { useForm } from '@mantine/form';
import { useLogStream } from '@/hooks/useLogStream';
import {
ActionIcon,
Box,
Expand All @@ -18,17 +34,7 @@ import {
ThemeIcon,
Tooltip,
} from '@mantine/core';

Check failure on line 36 in src/pages/Home/CreateStreamModal.tsx

View workflow job for this annotation

GitHub Actions / prettier

Delete `⏎`
import { FC, useCallback, useEffect, useState } from 'react';
import styles from './styles/CreateStreamModal.module.css';
import { useLogStream } from '@/hooks/useLogStream';
import { useForm } from '@mantine/form';
import { IconInfoCircleFilled, IconPlus } from '@tabler/icons-react';
import _ from 'lodash';
import { CreatableSelect } from '@/components/Misc/CreatableSelect';
import { useAppStore, appStoreReducers } from '@/layouts/MainLayout/providers/AppProvider';
import { GetInputPropsReturnType, UseFormReturnType } from 'node_modules/@mantine/form/lib/types';
import { notifyError } from '@/utils/notification';
import { LogStreamSchemaData } from '@/@types/parseable/api/stream';


const { toggleCreateStreamModal } = appStoreReducers;

Expand Down Expand Up @@ -461,9 +467,7 @@ const DetectSchemaSection = (props: { form: StreamFormType }) => {
} catch (e) {
console.error('Error parsing json', e);
}
if (!_.isArray(logRecords)) {
return notifyError({ message: 'Invalid JSON' });
} else if (_.isEmpty(logRecords)) {
if (_.isEmpty(logRecords)) {
return notifyError({ message: 'No records found' });
} else if (_.size(logRecords) > 10) {
return notifyError({ message: 'More than 10 records found' });
Expand Down

0 comments on commit f9f0337

Please sign in to comment.