diff --git a/src/AdminGuesser.test.tsx b/src/core/AdminGuesser.test.tsx similarity index 94% rename from src/AdminGuesser.test.tsx rename to src/core/AdminGuesser.test.tsx index 3c257f9e..b2d701d0 100644 --- a/src/AdminGuesser.test.tsx +++ b/src/core/AdminGuesser.test.tsx @@ -5,13 +5,13 @@ import ReactTestRenderer from 'react-test-renderer/shallow'; import AdminGuesser from './AdminGuesser.js'; import { AdminResourcesGuesser } from './AdminResourcesGuesser.js'; import ResourceGuesser from './ResourceGuesser.js'; -import schemaAnalyzer from './hydra/schemaAnalyzer.js'; -import resources from './__fixtures__/resources.js'; -import { API_DATA } from './__fixtures__/parsedData.js'; +import schemaAnalyzer from '../hydra/schemaAnalyzer.js'; +import resources from '../__fixtures__/resources.js'; +import { API_DATA } from '../__fixtures__/parsedData.js'; import type { ApiPlatformAdminDataProvider, ApiPlatformAdminRecord, -} from './types.js'; +} from '../types.js'; const dataProvider: ApiPlatformAdminDataProvider = { getList: () => Promise.resolve({ data: [], total: 0 }), diff --git a/src/AdminGuesser.tsx b/src/core/AdminGuesser.tsx similarity index 94% rename from src/AdminGuesser.tsx rename to src/core/AdminGuesser.tsx index 92451e5e..f5edbd74 100644 --- a/src/AdminGuesser.tsx +++ b/src/core/AdminGuesser.tsx @@ -6,16 +6,16 @@ import type { AdminProps } from 'react-admin'; import type { Resource } from '@api-platform/api-doc-parser'; import { AdminResourcesGuesser } from './AdminResourcesGuesser.js'; -import IntrospectionContext from './IntrospectionContext.js'; -import SchemaAnalyzerContext from './SchemaAnalyzerContext.js'; +import IntrospectionContext from '../introspection/IntrospectionContext.js'; +import SchemaAnalyzerContext from '../introspection/SchemaAnalyzerContext.js'; import { Error as DefaultError, Layout, LoginPage, darkTheme, lightTheme, -} from './layout/index.js'; -import type { ApiPlatformAdminDataProvider, SchemaAnalyzer } from './types.js'; +} from '../layout/index.js'; +import type { ApiPlatformAdminDataProvider, SchemaAnalyzer } from '../types.js'; export interface AdminGuesserProps extends AdminProps { admin?: ComponentType; diff --git a/src/AdminResourcesGuesser.tsx b/src/core/AdminResourcesGuesser.tsx similarity index 94% rename from src/AdminResourcesGuesser.tsx rename to src/core/AdminResourcesGuesser.tsx index 877b5da9..1c81c956 100644 --- a/src/AdminResourcesGuesser.tsx +++ b/src/core/AdminResourcesGuesser.tsx @@ -8,9 +8,9 @@ import ResourceGuesser from './ResourceGuesser.js'; import getRoutesAndResourcesFromNodes, { isSingleChildFunction, -} from './getRoutesAndResourcesFromNodes.js'; -import useDisplayOverrideCode from './useDisplayOverrideCode.js'; -import type { ApiPlatformAdminDataProvider, SchemaAnalyzer } from './types.js'; +} from '../introspection/getRoutesAndResourcesFromNodes.js'; +import useDisplayOverrideCode from '../useDisplayOverrideCode.js'; +import type { ApiPlatformAdminDataProvider, SchemaAnalyzer } from '../types.js'; export interface AdminGuesserProps extends AdminProps { admin?: ComponentType; diff --git a/src/ResourceGuesser.test.tsx b/src/core/ResourceGuesser.test.tsx similarity index 100% rename from src/ResourceGuesser.test.tsx rename to src/core/ResourceGuesser.test.tsx diff --git a/src/ResourceGuesser.tsx b/src/core/ResourceGuesser.tsx similarity index 88% rename from src/ResourceGuesser.tsx rename to src/core/ResourceGuesser.tsx index 975cca5e..6f74ab4d 100644 --- a/src/ResourceGuesser.tsx +++ b/src/core/ResourceGuesser.tsx @@ -5,15 +5,15 @@ import { useResourceDefinitionContext, } from 'react-admin'; import type { ResourceDefinition, ResourceProps } from 'react-admin'; -import ListGuesser from './ListGuesser.js'; -import CreateGuesser from './CreateGuesser.js'; -import EditGuesser from './EditGuesser.js'; -import ShowGuesser from './ShowGuesser.js'; -import Introspecter from './Introspecter.js'; +import ListGuesser from '../list/ListGuesser.js'; +import CreateGuesser from '../create/CreateGuesser.js'; +import EditGuesser from '../edit/EditGuesser.js'; +import ShowGuesser from '../show/ShowGuesser.js'; +import Introspecter from '../introspection/Introspecter.js'; import type { IntrospectedResourceGuesserProps, ResourceGuesserProps, -} from './types.js'; +} from '../types.js'; export const IntrospectedResourceGuesser = ({ resource, diff --git a/src/core/__snapshots__/AdminGuesser.test.tsx.snap b/src/core/__snapshots__/AdminGuesser.test.tsx.snap new file mode 100644 index 00000000..85acc1f7 --- /dev/null +++ b/src/core/__snapshots__/AdminGuesser.test.tsx.snap @@ -0,0 +1,77 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[` renders loading 1`] = ``; + +exports[` renders with custom resources 1`] = ` + + + +`; + +exports[` renders without custom resources 1`] = ` + + + +`; + +exports[` renders without data 1`] = ` + +`; diff --git a/src/core/__snapshots__/ResourceGuesser.test.tsx.snap b/src/core/__snapshots__/ResourceGuesser.test.tsx.snap new file mode 100644 index 00000000..1e960363 --- /dev/null +++ b/src/core/__snapshots__/ResourceGuesser.test.tsx.snap @@ -0,0 +1,61 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[` renders with create 1`] = ` + +`; + +exports[` renders with edit 1`] = ` + +`; + +exports[` renders with list 1`] = ` + +`; + +exports[` renders with show 1`] = ` + +`; + +exports[` renders without create 1`] = ` + +`; + +exports[` renders without edit 1`] = ` + +`; + +exports[` renders without list 1`] = ` + +`; + +exports[` renders without show 1`] = ` + +`; diff --git a/src/CreateGuesser.test.tsx b/src/create/CreateGuesser.test.tsx similarity index 94% rename from src/CreateGuesser.test.tsx rename to src/create/CreateGuesser.test.tsx index 7ac15acd..2d79fdb2 100644 --- a/src/CreateGuesser.test.tsx +++ b/src/create/CreateGuesser.test.tsx @@ -5,14 +5,14 @@ import { render, screen, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import CreateGuesser from './CreateGuesser.js'; -import SchemaAnalyzerContext from './SchemaAnalyzerContext.js'; -import schemaAnalyzer from './hydra/schemaAnalyzer.js'; +import SchemaAnalyzerContext from '../introspection/SchemaAnalyzerContext.js'; +import schemaAnalyzer from '../hydra/schemaAnalyzer.js'; import type { ApiPlatformAdminDataProvider, ApiPlatformAdminRecord, -} from './types.js'; +} from '../types.js'; -import { API_FIELDS_DATA } from './__fixtures__/parsedData.js'; +import { API_FIELDS_DATA } from '../__fixtures__/parsedData.js'; const hydraSchemaAnalyzer = schemaAnalyzer(); const dataProvider: ApiPlatformAdminDataProvider = { diff --git a/src/CreateGuesser.tsx b/src/create/CreateGuesser.tsx similarity index 91% rename from src/CreateGuesser.tsx rename to src/create/CreateGuesser.tsx index 3000d983..dcb6c245 100644 --- a/src/CreateGuesser.tsx +++ b/src/create/CreateGuesser.tsx @@ -8,14 +8,14 @@ import { } from 'react-admin'; import type { Field, Resource } from '@api-platform/api-doc-parser'; -import InputGuesser from './InputGuesser.js'; -import Introspecter from './Introspecter.js'; -import useDisplayOverrideCode from './useDisplayOverrideCode.js'; -import useOnSubmit from './useOnSubmit.js'; +import InputGuesser from '../input/InputGuesser.js'; +import Introspecter from '../introspection/Introspecter.js'; +import useDisplayOverrideCode from '../useDisplayOverrideCode.js'; +import useOnSubmit from '../useOnSubmit.js'; import type { CreateGuesserProps, IntrospectedCreateGuesserProps, -} from './types.js'; +} from '../types.js'; const getOverrideCode = (schema: Resource, fields: Field[]) => { let code = diff --git a/src/EditGuesser.test.tsx b/src/edit/EditGuesser.test.tsx similarity index 96% rename from src/EditGuesser.test.tsx rename to src/edit/EditGuesser.test.tsx index 8ac8ae8a..d6dedfff 100644 --- a/src/EditGuesser.test.tsx +++ b/src/edit/EditGuesser.test.tsx @@ -5,14 +5,14 @@ import { render, screen, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import EditGuesser from './EditGuesser.js'; -import SchemaAnalyzerContext from './SchemaAnalyzerContext.js'; -import schemaAnalyzer from './hydra/schemaAnalyzer.js'; +import SchemaAnalyzerContext from '../introspection/SchemaAnalyzerContext.js'; +import schemaAnalyzer from '../hydra/schemaAnalyzer.js'; import type { ApiPlatformAdminDataProvider, ApiPlatformAdminRecord, -} from './types.js'; +} from '../types.js'; -import { API_FIELDS_DATA } from './__fixtures__/parsedData.js'; +import { API_FIELDS_DATA } from '../__fixtures__/parsedData.js'; const hydraSchemaAnalyzer = schemaAnalyzer(); const dataProvider: ApiPlatformAdminDataProvider = { diff --git a/src/EditGuesser.tsx b/src/edit/EditGuesser.tsx similarity index 90% rename from src/EditGuesser.tsx rename to src/edit/EditGuesser.tsx index a698b09a..2b26cbf2 100644 --- a/src/EditGuesser.tsx +++ b/src/edit/EditGuesser.tsx @@ -9,15 +9,15 @@ import { import { useParams } from 'react-router-dom'; import type { Field, Resource } from '@api-platform/api-doc-parser'; -import InputGuesser from './InputGuesser.js'; -import Introspecter from './Introspecter.js'; -import useMercureSubscription from './useMercureSubscription.js'; -import useDisplayOverrideCode from './useDisplayOverrideCode.js'; -import useOnSubmit from './useOnSubmit.js'; +import InputGuesser from '../input/InputGuesser.js'; +import Introspecter from '../introspection/Introspecter.js'; +import useMercureSubscription from '../mercure/useMercureSubscription.js'; +import useDisplayOverrideCode from '../useDisplayOverrideCode.js'; +import useOnSubmit from '../useOnSubmit.js'; import type { EditGuesserProps, IntrospectedEditGuesserProps, -} from './types.js'; +} from '../types.js'; const getOverrideCode = (schema: Resource, fields: Field[]) => { let code = diff --git a/src/EnumField.tsx b/src/field/EnumField.tsx similarity index 94% rename from src/EnumField.tsx rename to src/field/EnumField.tsx index 835b6259..ddf67b72 100644 --- a/src/EnumField.tsx +++ b/src/field/EnumField.tsx @@ -6,7 +6,7 @@ import { useRecordContext, } from 'react-admin'; import type { TextFieldProps } from 'react-admin'; -import type { EnumFieldProps } from './types.js'; +import type { EnumFieldProps } from '../types.js'; const EnumField = ({ transformEnum, source, ...props }: EnumFieldProps) => { const record = useRecordContext(); diff --git a/src/FieldGuesser.test.tsx b/src/field/FieldGuesser.test.tsx similarity index 94% rename from src/FieldGuesser.test.tsx rename to src/field/FieldGuesser.test.tsx index f23c6ae5..61475cc2 100644 --- a/src/FieldGuesser.test.tsx +++ b/src/field/FieldGuesser.test.tsx @@ -4,14 +4,14 @@ import { Resource } from '@api-platform/api-doc-parser'; import { render, screen, waitFor } from '@testing-library/react'; import FieldGuesser from './FieldGuesser.js'; -import SchemaAnalyzerContext from './SchemaAnalyzerContext.js'; -import schemaAnalyzer from './hydra/schemaAnalyzer.js'; +import SchemaAnalyzerContext from '../introspection/SchemaAnalyzerContext.js'; +import schemaAnalyzer from '../hydra/schemaAnalyzer.js'; import type { ApiPlatformAdminDataProvider, ApiPlatformAdminRecord, -} from './types.js'; +} from '../types.js'; -import { API_FIELDS_DATA } from './__fixtures__/parsedData.js'; +import { API_FIELDS_DATA } from '../__fixtures__/parsedData.js'; const hydraSchemaAnalyzer = schemaAnalyzer(); const dataProvider: ApiPlatformAdminDataProvider = { diff --git a/src/FieldGuesser.tsx b/src/field/FieldGuesser.tsx similarity index 98% rename from src/FieldGuesser.tsx rename to src/field/FieldGuesser.tsx index d9cdb82b..294c8994 100644 --- a/src/FieldGuesser.tsx +++ b/src/field/FieldGuesser.tsx @@ -28,7 +28,7 @@ import type { } from 'react-admin'; import type { Field, Resource } from '@api-platform/api-doc-parser'; -import Introspecter from './Introspecter.js'; +import Introspecter from '../introspection/Introspecter.js'; import EnumField from './EnumField.js'; import type { EnumFieldProps, @@ -36,7 +36,7 @@ import type { FieldProps, IntrospectedFieldGuesserProps, SchemaAnalyzer, -} from './types.js'; +} from '../types.js'; const isFieldSortable = (field: Field, schema: Resource) => !!schema.parameters && diff --git a/src/getIdentifierValue.test.ts b/src/getIdentifierValue.test.ts index 426c90ef..8e0ed3db 100644 --- a/src/getIdentifierValue.test.ts +++ b/src/getIdentifierValue.test.ts @@ -3,7 +3,7 @@ import getIdentifierValue from './getIdentifierValue.js'; import { getFiltersParametersFromSchema, getOrderParametersFromSchema, -} from './schemaAnalyzer.js'; +} from './introspection/schemaAnalyzer.js'; import type { SchemaAnalyzer } from './types.js'; const schemaAnalyzer: SchemaAnalyzer = { diff --git a/src/hydra/HydraAdmin.tsx b/src/hydra/HydraAdmin.tsx index 5605f734..02616045 100644 --- a/src/hydra/HydraAdmin.tsx +++ b/src/hydra/HydraAdmin.tsx @@ -1,8 +1,8 @@ import React from 'react'; import dataProviderFactory from './dataProvider.js'; import /* tree-shaking no-side-effects-when-called */ schemaAnalyzer from './schemaAnalyzer.js'; -import AdminGuesser from '../AdminGuesser.js'; -import type { AdminGuesserProps } from '../AdminGuesser.js'; +import AdminGuesser from '../core/AdminGuesser.js'; +import type { AdminGuesserProps } from '../core/AdminGuesser.js'; import type { MercureOptions } from '../types.js'; type AdminGuesserPartialProps = Omit< diff --git a/src/hydra/dataProvider.ts b/src/hydra/dataProvider.ts index a98d7ff1..48009285 100644 --- a/src/hydra/dataProvider.ts +++ b/src/hydra/dataProvider.ts @@ -23,7 +23,7 @@ import type { } from 'react-admin'; import fetchHydra from './fetchHydra.js'; -import { resolveSchemaParameters } from '../schemaAnalyzer.js'; +import { resolveSchemaParameters } from '../introspection/schemaAnalyzer.js'; import { adminDataProvider } from '../dataProvider/index.js'; import { mercureManager } from '../mercure/index.js'; import { removeTrailingSlash } from '../removeTrailingSlash.js'; diff --git a/src/hydra/schemaAnalyzer.ts b/src/hydra/schemaAnalyzer.ts index b8d53029..36b8da86 100644 --- a/src/hydra/schemaAnalyzer.ts +++ b/src/hydra/schemaAnalyzer.ts @@ -4,7 +4,7 @@ import type { JsonLdObj } from 'jsonld/jsonld-spec'; import { getFiltersParametersFromSchema, getOrderParametersFromSchema, -} from '../schemaAnalyzer.js'; +} from '../introspection/schemaAnalyzer.js'; import type { SchemaAnalyzer, SubmissionErrors } from '../types.js'; const withHttpScheme = (value: string | null | undefined) => diff --git a/src/index.ts b/src/index.ts index 5232bafa..8bed6758 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,16 +1,16 @@ -import AdminGuesser from './AdminGuesser.js'; -import CreateGuesser from './CreateGuesser.js'; -import EditGuesser from './EditGuesser.js'; -import FieldGuesser from './FieldGuesser.js'; -import InputGuesser from './InputGuesser.js'; -import Introspecter from './Introspecter.js'; -import ListGuesser from './ListGuesser.js'; -import ResourceGuesser from './ResourceGuesser.js'; -import SchemaAnalyzerContext from './SchemaAnalyzerContext.js'; -import ShowGuesser from './ShowGuesser.js'; -import useIntrospect from './useIntrospect.js'; -import useIntrospection from './useIntrospection.js'; -import useMercureSubscription from './useMercureSubscription.js'; +import AdminGuesser from './core/AdminGuesser.js'; +import CreateGuesser from './create/CreateGuesser.js'; +import EditGuesser from './edit/EditGuesser.js'; +import FieldGuesser from './field/FieldGuesser.js'; +import InputGuesser from './input/InputGuesser.js'; +import Introspecter from './introspection/Introspecter.js'; +import ListGuesser from './list/ListGuesser.js'; +import ResourceGuesser from './core/ResourceGuesser.js'; +import SchemaAnalyzerContext from './introspection/SchemaAnalyzerContext.js'; +import ShowGuesser from './show/ShowGuesser.js'; +import useIntrospect from './introspection/useIntrospect.js'; +import useIntrospection from './introspection/useIntrospection.js'; +import useMercureSubscription from './mercure/useMercureSubscription.js'; import useOnSubmit from './useOnSubmit.js'; export { diff --git a/src/InputGuesser.test.tsx b/src/input/InputGuesser.test.tsx similarity index 98% rename from src/InputGuesser.test.tsx rename to src/input/InputGuesser.test.tsx index 2a73a86d..7e676e6d 100644 --- a/src/InputGuesser.test.tsx +++ b/src/input/InputGuesser.test.tsx @@ -11,14 +11,14 @@ import { fireEvent, render, screen, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import InputGuesser from './InputGuesser.js'; -import SchemaAnalyzerContext from './SchemaAnalyzerContext.js'; -import schemaAnalyzer from './hydra/schemaAnalyzer.js'; +import SchemaAnalyzerContext from '../introspection/SchemaAnalyzerContext.js'; +import schemaAnalyzer from '../hydra/schemaAnalyzer.js'; import type { ApiPlatformAdminDataProvider, ApiPlatformAdminRecord, -} from './types.js'; +} from '../types.js'; -import { API_FIELDS_DATA } from './__fixtures__/parsedData.js'; +import { API_FIELDS_DATA } from '../__fixtures__/parsedData.js'; const hydraSchemaAnalyzer = schemaAnalyzer(); const dataProvider: ApiPlatformAdminDataProvider = { diff --git a/src/InputGuesser.tsx b/src/input/InputGuesser.tsx similarity index 97% rename from src/InputGuesser.tsx rename to src/input/InputGuesser.tsx index 3f372aa4..a380e6ac 100644 --- a/src/InputGuesser.tsx +++ b/src/input/InputGuesser.tsx @@ -27,12 +27,12 @@ import type { TextInputProps, } from 'react-admin'; import isPlainObject from 'lodash.isplainobject'; -import Introspecter from './Introspecter.js'; -import getIdentifierValue, { isIdentifier } from './getIdentifierValue.js'; +import Introspecter from '../introspection/Introspecter.js'; +import getIdentifierValue, { isIdentifier } from '../getIdentifierValue.js'; import type { InputGuesserProps, IntrospectedInputGuesserProps, -} from './types.js'; +} from '../types.js'; export const IntrospectedInputGuesser = ({ fields, diff --git a/src/Introspecter.tsx b/src/introspection/Introspecter.tsx similarity index 96% rename from src/Introspecter.tsx rename to src/introspection/Introspecter.tsx index 2bf60fc5..61164338 100644 --- a/src/Introspecter.tsx +++ b/src/introspection/Introspecter.tsx @@ -3,7 +3,7 @@ import { useLogoutIfAccessDenied } from 'react-admin'; import SchemaAnalyzerContext from './SchemaAnalyzerContext.js'; import useIntrospect from './useIntrospect.js'; -import type { IntrospecterProps, SchemaAnalyzer } from './types.js'; +import type { IntrospecterProps, SchemaAnalyzer } from '../types.js'; import ResourcesIntrospecter from './ResourcesIntrospecter.js'; const Introspecter = ({ diff --git a/src/IntrospectionContext.ts b/src/introspection/IntrospectionContext.ts similarity index 100% rename from src/IntrospectionContext.ts rename to src/introspection/IntrospectionContext.ts diff --git a/src/ResourcesIntrospecter.tsx b/src/introspection/ResourcesIntrospecter.tsx similarity index 96% rename from src/ResourcesIntrospecter.tsx rename to src/introspection/ResourcesIntrospecter.tsx index b929877a..44365a7a 100644 --- a/src/ResourcesIntrospecter.tsx +++ b/src/introspection/ResourcesIntrospecter.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import type { ResourcesIntrospecterProps } from './types.js'; +import type { ResourcesIntrospecterProps } from '../types.js'; const ResourcesIntrospecter = ({ component: Component, diff --git a/src/SchemaAnalyzerContext.ts b/src/introspection/SchemaAnalyzerContext.ts similarity index 79% rename from src/SchemaAnalyzerContext.ts rename to src/introspection/SchemaAnalyzerContext.ts index 5a32d4db..687c93ed 100644 --- a/src/SchemaAnalyzerContext.ts +++ b/src/introspection/SchemaAnalyzerContext.ts @@ -1,7 +1,7 @@ import { /* tree-shaking no-side-effects-when-called */ createContext, } from 'react'; -import type { SchemaAnalyzer } from './types.js'; +import type { SchemaAnalyzer } from '../types.js'; const SchemaAnalyzerContext = createContext(null); diff --git a/src/getRoutesAndResourcesFromNodes.tsx b/src/introspection/getRoutesAndResourcesFromNodes.tsx similarity index 100% rename from src/getRoutesAndResourcesFromNodes.tsx rename to src/introspection/getRoutesAndResourcesFromNodes.tsx diff --git a/src/schemaAnalyzer.ts b/src/introspection/schemaAnalyzer.ts similarity index 97% rename from src/schemaAnalyzer.ts rename to src/introspection/schemaAnalyzer.ts index 4795abc4..174aee5e 100644 --- a/src/schemaAnalyzer.ts +++ b/src/introspection/schemaAnalyzer.ts @@ -1,5 +1,5 @@ import type { Resource } from '@api-platform/api-doc-parser'; -import type { FilterParameter } from './types.js'; +import type { FilterParameter } from '../types.js'; /** * @param schema The schema of a resource diff --git a/src/useIntrospect.ts b/src/introspection/useIntrospect.ts similarity index 96% rename from src/useIntrospect.ts rename to src/introspection/useIntrospect.ts index dc888c3a..2dfe1e4b 100644 --- a/src/useIntrospect.ts +++ b/src/introspection/useIntrospect.ts @@ -4,7 +4,7 @@ import type { UseQueryOptions } from '@tanstack/react-query'; import type { ApiPlatformAdminDataProvider, IntrospectPayload, -} from './types.js'; +} from '../types.js'; const useIntrospect = (options?: UseQueryOptions) => { const dataProvider = useDataProvider(); diff --git a/src/useIntrospection.ts b/src/introspection/useIntrospection.ts similarity index 100% rename from src/useIntrospection.ts rename to src/introspection/useIntrospection.ts diff --git a/src/FilterGuesser.tsx b/src/list/FilterGuesser.tsx similarity index 90% rename from src/FilterGuesser.tsx rename to src/list/FilterGuesser.tsx index d498b817..85887fc5 100644 --- a/src/FilterGuesser.tsx +++ b/src/list/FilterGuesser.tsx @@ -1,12 +1,12 @@ import React, { useEffect, useState } from 'react'; import { Filter, useResourceContext } from 'react-admin'; -import InputGuesser from './InputGuesser.js'; -import Introspecter from './Introspecter.js'; +import InputGuesser from '../input/InputGuesser.js'; +import Introspecter from '../introspection/Introspecter.js'; import type { FilterGuesserProps, FilterParameter, IntrospectedFiterGuesserProps, -} from './types.js'; +} from '../types.js'; export const IntrospectedFilterGuesser = ({ fields, diff --git a/src/ListGuesser.tsx b/src/list/ListGuesser.tsx similarity index 93% rename from src/ListGuesser.tsx rename to src/list/ListGuesser.tsx index 6a0c90f3..76e8fde8 100644 --- a/src/ListGuesser.tsx +++ b/src/list/ListGuesser.tsx @@ -11,16 +11,16 @@ import { import type { DatagridBodyProps } from 'react-admin'; import type { Field, Resource } from '@api-platform/api-doc-parser'; -import FieldGuesser from './FieldGuesser.js'; +import FieldGuesser from '../field/FieldGuesser.js'; import FilterGuesser from './FilterGuesser.js'; -import Introspecter from './Introspecter.js'; -import useMercureSubscription from './useMercureSubscription.js'; -import useDisplayOverrideCode from './useDisplayOverrideCode.js'; +import Introspecter from '../introspection/Introspecter.js'; +import useMercureSubscription from '../mercure/useMercureSubscription.js'; +import useDisplayOverrideCode from '../useDisplayOverrideCode.js'; import type { ApiPlatformAdminRecord, IntrospectedListGuesserProps, ListGuesserProps, -} from './types.js'; +} from '../types.js'; const getOverrideCode = (schema: Resource, fields: Field[]) => { let code = diff --git a/src/useMercureSubscription.ts b/src/mercure/useMercureSubscription.ts similarity index 91% rename from src/useMercureSubscription.ts rename to src/mercure/useMercureSubscription.ts index 25366fc2..a272e096 100644 --- a/src/useMercureSubscription.ts +++ b/src/mercure/useMercureSubscription.ts @@ -1,8 +1,8 @@ import { useEffect, useRef } from 'react'; import { useDataProvider } from 'react-admin'; import type { Identifier } from 'react-admin'; -import { useUpdateCache } from './dataProvider/index.js'; -import type { ApiPlatformAdminDataProvider } from './types.js'; +import { useUpdateCache } from '../dataProvider/index.js'; +import type { ApiPlatformAdminDataProvider } from '../types.js'; export default function useMercureSubscription( resource: string | undefined, diff --git a/src/openapi/OpenApiAdmin.tsx b/src/openapi/OpenApiAdmin.tsx index 3c217637..74a69257 100644 --- a/src/openapi/OpenApiAdmin.tsx +++ b/src/openapi/OpenApiAdmin.tsx @@ -2,8 +2,8 @@ import React from 'react'; import dataProviderFactory from './dataProvider.js'; import { restDataProvider } from '../dataProvider/index.js'; import /* tree-shaking no-side-effects-when-called */ schemaAnalyzer from './schemaAnalyzer.js'; -import AdminGuesser from '../AdminGuesser.js'; -import type { AdminGuesserProps } from '../AdminGuesser.js'; +import AdminGuesser from '../core/AdminGuesser.js'; +import type { AdminGuesserProps } from '../core/AdminGuesser.js'; import type { MercureOptions } from '../types.js'; type AdminGuesserPartialProps = Omit< diff --git a/src/openapi/schemaAnalyzer.ts b/src/openapi/schemaAnalyzer.ts index f3892f2b..06c2b532 100644 --- a/src/openapi/schemaAnalyzer.ts +++ b/src/openapi/schemaAnalyzer.ts @@ -2,7 +2,7 @@ import type { Field, Resource } from '@api-platform/api-doc-parser'; import { getFiltersParametersFromSchema, getOrderParametersFromSchema, -} from '../schemaAnalyzer.js'; +} from '../introspection/schemaAnalyzer.js'; import type { SchemaAnalyzer } from '../types.js'; /** diff --git a/src/ShowGuesser.test.tsx b/src/show/ShowGuesser.test.tsx similarity index 96% rename from src/ShowGuesser.test.tsx rename to src/show/ShowGuesser.test.tsx index ee8b13ed..55fef4e9 100644 --- a/src/ShowGuesser.test.tsx +++ b/src/show/ShowGuesser.test.tsx @@ -10,14 +10,14 @@ import { render, screen, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import ShowGuesser from './ShowGuesser.js'; -import SchemaAnalyzerContext from './SchemaAnalyzerContext.js'; -import schemaAnalyzer from './hydra/schemaAnalyzer.js'; +import SchemaAnalyzerContext from '../introspection/SchemaAnalyzerContext.js'; +import schemaAnalyzer from '../hydra/schemaAnalyzer.js'; import type { ApiPlatformAdminDataProvider, ApiPlatformAdminRecord, -} from './types.js'; +} from '../types.js'; -import { API_FIELDS_DATA } from './__fixtures__/parsedData.js'; +import { API_FIELDS_DATA } from '../__fixtures__/parsedData.js'; const hydraSchemaAnalyzer = schemaAnalyzer(); const dataProvider: ApiPlatformAdminDataProvider = { diff --git a/src/ShowGuesser.tsx b/src/show/ShowGuesser.tsx similarity index 89% rename from src/ShowGuesser.tsx rename to src/show/ShowGuesser.tsx index 75f2dc3f..60ab01a8 100644 --- a/src/ShowGuesser.tsx +++ b/src/show/ShowGuesser.tsx @@ -9,14 +9,14 @@ import { import { useParams } from 'react-router-dom'; import type { Field, Resource } from '@api-platform/api-doc-parser'; -import FieldGuesser from './FieldGuesser.js'; -import Introspecter from './Introspecter.js'; -import useMercureSubscription from './useMercureSubscription.js'; -import useDisplayOverrideCode from './useDisplayOverrideCode.js'; +import FieldGuesser from '../field/FieldGuesser.js'; +import Introspecter from '../introspection/Introspecter.js'; +import useMercureSubscription from '../mercure/useMercureSubscription.js'; +import useDisplayOverrideCode from '../useDisplayOverrideCode.js'; import type { IntrospectedShowGuesserProps, ShowGuesserProps, -} from './types.js'; +} from '../types.js'; const getOverrideCode = (schema: Resource, fields: Field[]) => { let code =