Skip to content

Commit

Permalink
Add folder hierarchy
Browse files Browse the repository at this point in the history
  • Loading branch information
fzaninotto committed Jul 9, 2024
1 parent e12cd7f commit c99a968
Show file tree
Hide file tree
Showing 36 changed files with 233 additions and 95 deletions.
8 changes: 4 additions & 4 deletions src/AdminGuesser.test.tsx → src/core/AdminGuesser.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 }),
Expand Down
8 changes: 4 additions & 4 deletions src/AdminGuesser.tsx → src/core/AdminGuesser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<AdminProps>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<AdminProps>;
Expand Down
File renamed without changes.
12 changes: 6 additions & 6 deletions src/ResourceGuesser.tsx → src/core/ResourceGuesser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
77 changes: 77 additions & 0 deletions src/core/__snapshots__/AdminGuesser.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<AdminGuesser /> renders loading 1`] = `<Loading />`;

exports[`<AdminGuesser /> renders with custom resources 1`] = `
<AdminUI
dataProvider={
{
"create": [Function],
"delete": [Function],
"deleteMany": [Function],
"getList": [Function],
"getMany": [Function],
"getManyReference": [Function],
"getOne": [Function],
"introspect": [Function],
"subscribe": [Function],
"unsubscribe": [Function],
"update": [Function],
"updateMany": [Function],
}
}
loading={[Function]}
>
<ResourceGuesser
name="custom"
/>
</AdminUI>
`;

exports[`<AdminGuesser /> renders without custom resources 1`] = `
<AdminUI
dataProvider={
{
"create": [Function],
"delete": [Function],
"deleteMany": [Function],
"getList": [Function],
"getMany": [Function],
"getManyReference": [Function],
"getOne": [Function],
"introspect": [Function],
"subscribe": [Function],
"unsubscribe": [Function],
"update": [Function],
"updateMany": [Function],
}
}
loading={[Function]}
>
<ResourceGuesser
name="books"
/>
</AdminUI>
`;

exports[`<AdminGuesser /> renders without data 1`] = `
<AdminUI
dataProvider={
{
"create": [Function],
"delete": [Function],
"deleteMany": [Function],
"getList": [Function],
"getMany": [Function],
"getManyReference": [Function],
"getOne": [Function],
"introspect": [Function],
"subscribe": [Function],
"unsubscribe": [Function],
"update": [Function],
"updateMany": [Function],
}
}
loading={[Function]}
/>
`;
61 changes: 61 additions & 0 deletions src/core/__snapshots__/ResourceGuesser.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<ResourceGuesser /> renders with create 1`] = `
<Introspecter
component={[Function]}
create={[Function]}
resource="dummy"
/>
`;

exports[`<ResourceGuesser /> renders with edit 1`] = `
<Introspecter
component={[Function]}
edit={[Function]}
resource="dummy"
/>
`;

exports[`<ResourceGuesser /> renders with list 1`] = `
<Introspecter
component={[Function]}
list={[Function]}
resource="dummy"
/>
`;

exports[`<ResourceGuesser /> renders with show 1`] = `
<Introspecter
component={[Function]}
resource="dummy"
show={[Function]}
/>
`;

exports[`<ResourceGuesser /> renders without create 1`] = `
<Introspecter
component={[Function]}
resource="dummy"
/>
`;

exports[`<ResourceGuesser /> renders without edit 1`] = `
<Introspecter
component={[Function]}
resource="dummy"
/>
`;

exports[`<ResourceGuesser /> renders without list 1`] = `
<Introspecter
component={[Function]}
resource="dummy"
/>
`;

exports[`<ResourceGuesser /> renders without show 1`] = `
<Introspecter
component={[Function]}
resource="dummy"
/>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
10 changes: 5 additions & 5 deletions src/CreateGuesser.tsx → src/create/CreateGuesser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
8 changes: 4 additions & 4 deletions src/EditGuesser.test.tsx → src/edit/EditGuesser.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
12 changes: 6 additions & 6 deletions src/EditGuesser.tsx → src/edit/EditGuesser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
2 changes: 1 addition & 1 deletion src/EnumField.tsx → src/field/EnumField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
8 changes: 4 additions & 4 deletions src/FieldGuesser.test.tsx → src/field/FieldGuesser.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
4 changes: 2 additions & 2 deletions src/FieldGuesser.tsx → src/field/FieldGuesser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ 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,
FieldGuesserProps,
FieldProps,
IntrospectedFieldGuesserProps,
SchemaAnalyzer,
} from './types.js';
} from '../types.js';

const isFieldSortable = (field: Field, schema: Resource) =>
!!schema.parameters &&
Expand Down
2 changes: 1 addition & 1 deletion src/getIdentifierValue.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
4 changes: 2 additions & 2 deletions src/hydra/HydraAdmin.tsx
Original file line number Diff line number Diff line change
@@ -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<
Expand Down
2 changes: 1 addition & 1 deletion src/hydra/dataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/hydra/schemaAnalyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down
Loading

0 comments on commit c99a968

Please sign in to comment.